Created
November 30, 2017 19:55
-
-
Save Naoray/2649481a02836fc333fd420d36464e97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\SparkExtensions; | |
use Illuminate\Support\Facades\Validator; | |
use Laravel\Spark\Events\Profile\ContactInformationUpdated; | |
use Laravel\Spark\Interactions\Settings\Profile\UpdateContactInformation as SparkUpdateContactInformation; | |
class UpdateContactInformation extends SparkUpdateContactInformation | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function validator($user, array $data) | |
{ | |
return Validator::make($data, [ | |
'name' => 'required|max:255', | |
'email' => 'required|email|unique:users,email,'.$user->id, | |
]); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function handle($user, array $data) | |
{ | |
$user->forceFill([ | |
'name' => $data['name'], | |
'email' => $data['email'], | |
'phone' => $data['phone'], | |
])->save(); | |
event(new ContactInformationUpdated($user)); | |
return $user; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment