Support the ongoing development of Laravel.io →
Eloquent Views
Last updated 1 year ago.
0

I usually opt for this:

User::where('first_name', 'simon');    
Last updated 1 year ago.
0

In fact you are wrong about Eloquent with as it's not working dynamically like where

Last updated 1 year ago.
0

jarektkaczyk said:

In fact you are wrong about Eloquent with as it's not working dynamically like where

it does work differently, but still has that magic to it. with the eloquent where you can do crazier stuff (thanks to dynamicWhere() method) like this:

User::whereFirstNameAndId('simon', 1);
// same as
User::where('first_name', 'simon')->where('id', 1);

whereas in View you're limited to only one magic parameter.

View::make('base')->withSomeVar($val);
// same as
View::make('base')->with('someVar', $val);
Last updated 1 year ago.
0

Yes, of course you can do that.

For Eloquent Builder itself scopes are working just the same. And there are more of this magic in L4

What I mean is, that it's Query Builder's feature (dynamic where for queries), and View and RedirectResponse (dynamic with on the View like in your example and return Redirect::to()->withInput()->withSomethingElse()), while there's no dynamic with for Eloquent (whereas with loads relations).

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

zwacky zwacky Joined 31 Jan 2014

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.

© 2024 Laravel.io - All rights reserved.