Add updating event that fires before saving

Signed-off-by: 's avatarMicheal Mand <micheal@kmdwebdesigns.com>
parent f89d9277
<?php
namespace Modules\User\Events;
class UserIsUpdating
{
public $user;
public function __construct($user)
{
$this->user = $user;
}
}
...@@ -7,6 +7,7 @@ use Cartalyst\Sentinel\Laravel\Facades\Sentinel; ...@@ -7,6 +7,7 @@ use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Modules\User\Entities\Sentinel\User; use Modules\User\Entities\Sentinel\User;
use Modules\User\Events\UserHasRegistered; use Modules\User\Events\UserHasRegistered;
use Modules\User\Events\UserIsUpdating;
use Modules\User\Events\UserWasCreated; use Modules\User\Events\UserWasCreated;
use Modules\User\Events\UserWasUpdated; use Modules\User\Events\UserWasUpdated;
use Modules\User\Exceptions\UserNotFoundException; use Modules\User\Exceptions\UserNotFoundException;
...@@ -120,7 +121,11 @@ class SentinelUserRepository implements UserRepository ...@@ -120,7 +121,11 @@ class SentinelUserRepository implements UserRepository
*/ */
public function update($user, $data) public function update($user, $data)
{ {
$user->update($data); $user->fill($data);
event(new UserIsUpdating($user));
$user->save();
event(new UserWasUpdated($user)); event(new UserWasUpdated($user));
...@@ -143,6 +148,9 @@ class SentinelUserRepository implements UserRepository ...@@ -143,6 +148,9 @@ class SentinelUserRepository implements UserRepository
$this->checkForManualActivation($user, $data); $this->checkForManualActivation($user, $data);
$user = $user->fill($data); $user = $user->fill($data);
event(new UserIsUpdating($user));
$user->save(); $user->save();
event(new UserWasUpdated($user)); event(new UserWasUpdated($user));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment