mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 06:20:21 +00:00
24 lines
567 B
PHP
24 lines
567 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Events\MasterTaskEdited;
|
|
use App\Models\MasterTask;
|
|
|
|
class MasterTaskObserver
|
|
{
|
|
public function creating(MasterTask $mastertask)
|
|
{
|
|
$mastertask->color = MasterTask::generateMasterTaskColor();
|
|
}
|
|
|
|
public function updating(MasterTask $mastertask)
|
|
{
|
|
// to prevent updating created_by field. this field cannot be updated once created.
|
|
$mastertask->created_by = $mastertask->getOriginal('created_by');
|
|
|
|
MasterTaskEdited::dispatch($mastertask, $mastertask->getOriginal());
|
|
|
|
}
|
|
}
|