#1947 puan modülü

This commit is contained in:
Diatrex 2020-09-22 13:51:03 +03:00
parent 82c8855e1a
commit dcb2464079
3 changed files with 50 additions and 4 deletions

View File

@ -0,0 +1,13 @@
<?php namespace Visiosoft\ProfileModule\Events;
class UserUpdated
{
public $oldCustomerInfo;
public $changes;
public function __construct($oldCustomerInfo, $changes)
{
$this->oldCustomerInfo = $oldCustomerInfo;
$this->changes = $changes;
}
}

View File

@ -2,7 +2,7 @@
use Anomaly\Streams\Platform\Message\MessageBag;
use Anomaly\UsersModule\User\UserModel;
use Illuminate\Support\Facades\Auth;
use Visiosoft\ProfileModule\Events\UserUpdated;
class ProfileFormHandler
{
@ -30,8 +30,25 @@ class ProfileFormHandler
$parameters['file_id'] = null;
}
$userModel->newQuery()->where('id', Auth::id())->update($parameters);
$user = $userModel->newQuery()->find(\auth()->id());
$oldCustomerInfo = $user->toArray();
$changes = $this->change($user, $parameters);
event(new UserUpdated($oldCustomerInfo, $changes));
$messages->success(trans('visiosoft.module.profile::message.success_update'));
}
public function change($user, $data)
{
$user->fill($data);
$changes = $user->getDirty();
$user->save();
if (count($changes) == 0) {
return false;
}
return $changes;
}
}

View File

@ -2,8 +2,8 @@
use Anomaly\Streams\Platform\Message\MessageBag;
use Anomaly\UsersModule\User\UserModel;
use Illuminate\Support\Facades\Auth;
use Visiosoft\NotificationsModule\Notify\Notification\UserUpdateEmailMail;
use Visiosoft\ProfileModule\Events\UserUpdated;
class UserFormHandler
{
@ -24,7 +24,23 @@ class UserFormHandler
$user->notify(new UserUpdateEmailMail());
}
$user->update($builder->getPostData());
$oldCustomerInfo = $user->toArray();
$changes = $this->change($user, $data);
event(new UserUpdated($oldCustomerInfo, $changes));
$messages->success(trans('visiosoft.module.profile::message.success_update'));
}
public function change($user, $data)
{
$user->fill($data);
$changes = $user->getDirty();
$user->save();
if (count($changes) == 0) {
return false;
}
return $changes;
}
}