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:
ehsan
2025-03-12 11:57:11 +03:30
parent 71e493ec10
commit 5fe7474227
5 changed files with 86 additions and 2 deletions
+12
View File
@@ -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);