mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-13 02:01:07 +03:30
remove the validation for cycle number in store label and add an eloquent event for updating cycle number when cycle is saved.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\CycleSaved;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -14,6 +15,17 @@ class Cycle extends Model
|
||||
'date', 'user_id', 'cycle_number', 'sterilizer_id', 'note', 'verified', 'unique_id'
|
||||
];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::created(function ($cycle) {
|
||||
event(new CycleSaved($cycle));
|
||||
});
|
||||
|
||||
static::updated(function ($cycle) {
|
||||
event(new CycleSaved($cycle));
|
||||
});
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
|
||||
Reference in New Issue
Block a user