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

Popular posts from this blog

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -