secara otomatis membuat create_by dan update_by menggunakan pengamat laravel
<?php
<?php
namespace App\Observers;
class RecordFingerPrintObserver {
$userID;
public function __construct($userID){
$user = Auth::user();
$this->userID = $user->getId();
}
public function saving($model)
{
$model->modfied_by = $this->userID;
}
public function saved($model)
{
$model->modfied_by = $this->userID;
}
public function updating($model)
{
$model->modfied_by = $this->userID;
}
public function updated($model)
{
$model->modfied_by = $this->userID;
}
public function creating($model)
{
$model->created_by = $this->userID;
}
public function created($model)
{
$model->created_by = $this->userID;
}
public function removing($model)
{
$model->purged_by = $this->userID;
}
public function removed($model)
{
$model->purged_by = $this->userID;
}
}
Irfan