laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

can we have helpers like "abort_if()"? for other actions? #2429

Open MuhammedAlkhudiry opened 3 years ago

MuhammedAlkhudiry commented 3 years ago

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:

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.