How can I apply a status (condition) check direct to a model in laravel? -
i have added status column product table. want when use product::all()
product status active. soft delete. want model ignores products passive until activated again. there way this?
ps: used model (product::class) in tons of places. looking direct way affects methods made already. otherwise have apply solution methods 1 one.
if you're looking same functionality soft deletes, can use global scopes. softdeletes
trait uses global scope. so, if you'll apply global scope product
model product::all()
return results status = 1
.
Comments
Post a Comment