User Listener

This commit is contained in:
David Bomba 2019-04-22 09:15:07 +10:00
parent f3994f4a07
commit ab07513e3d
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,40 @@
<?php
namespace App\Listeners\User;
use App\Models\Activity;
use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
class CreatedUserActivity
{
protected $activityRepo;
/**
* Create the event listener.
*
* @return void
*/
public function __construct(ActivityRepository $activityRepo)
{
$this->activityRepo = $activityRepo;
}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
{
$fields = new \stdClass;
$fields->user_id = auth()->user()->id;
$fields->company_id = $event->user->company_id;
$fields->activity_type_id = Activity::CREATE_USER;
$this->activityRepo->save($fields, $event->user);
}
}

View File

@ -52,13 +52,18 @@ class Activity extends BaseModel
const DELETE_TASK=45;
const RESTORE_TASK=46;
const UPDATE_EXPENSE=47;
const CREATE_USER=48;
const UPDATE_USER=49;
const ARCHIVE_USER=50;
const DELETE_USER=51;
const RESTORE_USER=52;
public function backup()
{
return $this->hasOne(Backup::class);
}
/**
* @return mixed
*/