2017-06-15 20:54:14 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Observers;
|
|
|
|
|
|
|
|
use App\Models\Component;
|
|
|
|
use App\Models\Setting;
|
|
|
|
use App\Models\Actionlog;
|
|
|
|
use Auth;
|
|
|
|
|
|
|
|
class ComponentObserver
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Listen to the User created event.
|
|
|
|
*
|
|
|
|
* @param Component $component
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function updated(Component $component)
|
|
|
|
{
|
|
|
|
|
|
|
|
$logAction = new Actionlog();
|
|
|
|
$logAction->item_type = Component::class;
|
|
|
|
$logAction->item_id = $component->id;
|
|
|
|
$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 Component created event when
|
2017-06-15 20:54:14 -07:00
|
|
|
* a new component is created.
|
|
|
|
*
|
|
|
|
* @param Component $component
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function created(Component $component)
|
|
|
|
{
|
|
|
|
$logAction = new Actionlog();
|
|
|
|
$logAction->item_type = Component::class;
|
|
|
|
$logAction->item_id = $component->id;
|
|
|
|
$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 Component deleting event.
|
|
|
|
*
|
|
|
|
* @param Component $component
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function deleting(Component $component)
|
|
|
|
{
|
|
|
|
$logAction = new Actionlog();
|
|
|
|
$logAction->item_type = Component::class;
|
|
|
|
$logAction->item_id = $component->id;
|
|
|
|
$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');
|
|
|
|
}
|
|
|
|
}
|