You need to add ->get(), ->first(), etc. at the end.
raimckenzie said:
You need to add -
>get(),->first(), etc. at the end.
my question is "Eloquent Model Class has not where method. but execute correctly without error. HOW?"
http://laravel.com/api/master/Illuminate/Database/Eloquent/Model.html#method___callStatic You can see how it executes here — https://github.com/laravel/framework/blob/master/src/Illuminate/Database/Eloquent/Model.php#L3134 .
When you call the where method on an Eloquent/Model instance the Model class delegates it to the underlying \Illuminate\Database\Eloquent\Builder instance ( Please see the __callStatic and __call methods inside Model class ). The where method inside the \Illuminate\Database\Eloquent\Builder class is merely a wrapper ( see the implementation of the where method ) that actually further delegates the call to the actual where method which is defined inside the Illuminate\Database\Query\Builder class.
usm4n said:
When you call the
wheremethod on anEloquent/Modelinstance theModelclass delegates it to the underlying\Illuminate\Database\Eloquent\Builderinstance ( Please see the__callStaticand__callmethods insideModelclass ). Thewheremethod inside the\Illuminate\Database\Eloquent\Builderclass is merely a wrapper ( see the implementation of thewheremethod ) that actually further delegates the call to the actualwheremethod which is defined inside theIlluminate\Database\Query\Builderclass.
thank you so much!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.