Support the ongoing development of Laravel.io →
Eloquent Laravel Laravel.io
Last updated 8 months 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.

1

Sign in to participate in this thread!

Full Stack Europe

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.

© 2023 Laravel.io - All rights reserved.