Since We have abort_if() and similarly we have when() in query builder, why don't we have the same convenient methods for other actions.
I always see this:
if (....)
return redirect()>withErrors(['...']);
if (....)
return redirect()->withErrors(['...']);
and they can be cleaned up to be in one line.
we can extend it to many actions:
back_if()
User::createIf() or createWhen()
User::updateIf()
This can be limited to one action, and I think can be implemented using some magic in naming methods the same way methods like User::whereName() are implemented.
Since We have
abort_if()
and similarly we havewhen()
in query builder, why don't we have the same convenient methods for other actions.I always see this:
and they can be cleaned up to be in one line.
we can extend it to many actions:
back_if()
User::createIf()
orcreateWhen()
User::updateIf()
This can be limited to one action, and I think can be implemented using some magic in naming methods the same way methods like User::whereName() are implemented.