Knowing when it's a Model or a Builder(Laravel)

EDDYMENS
3 min readJan 7, 2019

User::where('id',1)->update([]) and User::find(1)->update([]) do the same thing but in different ways.

Erhn?

When working with databases in Laravel you usually find yourself either using Eloquent or the lower level Fluent queries.

Eloquent provides ways to “objectice” working with databases using the Fluent queries. Simply put its a wrapper around Fluent queries with extra cheese :).

Some underlying Mechanisms.

Generally, everything regarding Fluent queries can be found under the namespace Illuminate\Database\Query\Builder

And everything Eloquent under Illuminate\Database\Eloquent\Model

Further into Eloquent

If you know you know :)

Eloquent also has many parts to it, the main point of attraction the Model Class, Its own Query Builder Class as well other important classes like the Relations etc.

Examples Now let's try and break a couple of queries down

User::where('id',1) :This statement starts out as an eloquent model then once where is called the returned instance is that of the eloquent…

--

--