Move the model callbacks into Observables; reduce caching since it held balances incorrectly
This commit is contained in:
22
app/Models/Observers/JournalObserver.php
Normal file
22
app/Models/Observers/JournalObserver.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Observers;
|
||||
|
||||
use App\Models\Journal;
|
||||
|
||||
/**
|
||||
* Class JournalObserver
|
||||
* @package App\Models\Observers
|
||||
*/
|
||||
class JournalObserver
|
||||
{
|
||||
/**
|
||||
* @param Journal $journal
|
||||
* @throws \UnexpectedValueException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function creating(Journal $journal): void
|
||||
{
|
||||
$journal->balance = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user