2017-06-15 20:54:14 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Observers;
|
|
|
|
|
|
|
|
use App\Models\Actionlog;
|
2019-03-13 20:12:03 -07:00
|
|
|
use App\Models\Consumable;
|
2017-06-15 20:54:14 -07:00
|
|
|
use Auth;
|
|
|
|
|
|
|
|
class ConsumableObserver
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Listen to the User created event.
|
|
|
|
*
|
|
|
|
* @param Consumable $consumable
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function updated(Consumable $consumable)
|
|
|
|
{
|
|
|
|
$logAction = new Actionlog();
|
|
|
|
$logAction->item_type = Consumable::class;
|
|
|
|
$logAction->item_id = $consumable->id;
|
2021-06-10 13:15:52 -07:00
|
|
|
$logAction->created_at = date('Y-m-d H:i:s');
|
2017-06-20 20:38:13 -07:00
|
|
|
$logAction->user_id = Auth::id();
|
2017-06-15 20:54:14 -07:00
|
|
|
$logAction->logaction('update');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-08-23 13:59:59 -07:00
|
|
|
* Listen to the Consumable created event when
|
2017-06-15 20:54:14 -07:00
|
|
|
* a new consumable is created.
|
|
|
|
*
|
|
|
|
* @param Consumable $consumable
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function created(Consumable $consumable)
|
|
|
|
{
|
|
|
|
$logAction = new Actionlog();
|
|
|
|
$logAction->item_type = Consumable::class;
|
|
|
|
$logAction->item_id = $consumable->id;
|
2021-06-10 13:15:52 -07:00
|
|
|
$logAction->created_at = date('Y-m-d H:i:s');
|
2017-06-20 20:38:13 -07:00
|
|
|
$logAction->user_id = Auth::id();
|
2017-06-15 20:54:14 -07:00
|
|
|
$logAction->logaction('create');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to the Consumable deleting event.
|
|
|
|
*
|
|
|
|
* @param Consumable $consumable
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function deleting(Consumable $consumable)
|
|
|
|
{
|
|
|
|
$logAction = new Actionlog();
|
|
|
|
$logAction->item_type = Consumable::class;
|
|
|
|
$logAction->item_id = $consumable->id;
|
2021-06-10 13:15:52 -07:00
|
|
|
$logAction->created_at = date('Y-m-d H:i:s');
|
2017-06-20 20:38:13 -07:00
|
|
|
$logAction->user_id = Auth::id();
|
2017-06-15 20:54:14 -07:00
|
|
|
$logAction->logaction('delete');
|
|
|
|
}
|
|
|
|
}
|