Skip to content

Instantly share code, notes, and snippets.

@Naoray
Created November 30, 2017 19:55
Show Gist options
  • Save Naoray/2649481a02836fc333fd420d36464e97 to your computer and use it in GitHub Desktop.
Save Naoray/2649481a02836fc333fd420d36464e97 to your computer and use it in GitHub Desktop.
<?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