Support the ongoing development of Laravel.io →
Eloquent Laravel Laravel.io
Last updated 1 year ago.
0

You don't have to save the model object inside the model event handler, it will eventually be saved, so this is enough:

protected static function boot()
    {
        parent::boot();
        static::saving(function ($model){
            if ($model->Qty <= 0)
             {
                $model->Status ='Not Available';
              }
            
            if ($model->Qty <= 5 && $model->Qty >= 1)
             {
                $model->Status ='Reorder level';
            }
        });
    }

Pls update and try again.

zworthkey liked this reply

1

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.