Merge branch 'trunk'
This commit is contained in:
commit
e4006145a2
1 changed files with 13 additions and 7 deletions
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\FileCreated;
|
||||
use App\Events\Loggable;
|
||||
use App\Events\ProjectUpdated;
|
||||
use App\Events\SiteUpdated;
|
||||
use App\Models\Log;
|
||||
|
||||
class HandleLoggable
|
||||
|
|
@ -15,14 +18,17 @@ class HandleLoggable
|
|||
*/
|
||||
public function handle(Loggable $loggable)
|
||||
{
|
||||
$log = new Log([
|
||||
'entry' => trans(':username à crée le fichier :filename', [
|
||||
'username' => $loggable->user->name,
|
||||
'filename' => $loggable->file->name
|
||||
])
|
||||
]);
|
||||
$log = new Log(['entry' => $loggable->message]);
|
||||
$log->user()->associate($loggable->user);
|
||||
$log->parent()->associate($loggable->file->parent);
|
||||
if (\get_class($loggable) === FileCreated::class) {
|
||||
$log->parent()->associate($loggable->file->parent);
|
||||
}
|
||||
if (\get_class($loggable) === SiteUpdated::class) {
|
||||
$log->parent()->associate($loggable->site);
|
||||
}
|
||||
if (\get_class($loggable) === ProjectUpdated::class) {
|
||||
$log->parent()->associate($loggable->project);
|
||||
}
|
||||
$log->saveOrFail();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue