<?php

namespace App\Traits;

use App\Events\CreatedContentEvent;
use App\Events\UpdatedContentEvent;
use App\Events\DeletedContentEvent;

trait LogsHistory
{
    public static function bootLogsHistory()
    {
        // $model::MODULE_SCREEN_NAME
        static::created(function ($model) {
            event(new CreatedContentEvent($model::class, \request(), $model));
        });

        static::updated(function ($model) {
            event(new UpdatedContentEvent($model::class, \request(), $model));
        });

        static::deleted(function ($model) {
            event(new DeletedContentEvent($model::class, \request(), $model));
        });
    }
}
