I have a server running php 5.3.22. When I make a call to an eloquent model I get an error:
$email = Email::with('recipient')->where('token', '=', $data['token'])->firstOrFail();
I get this error:
Call to undefined method Illuminate\Database\Query\Builder::firstOrFail()
When I try this on my other server running php 5.4.23 it works fine. Is this a known issue with php? I imagine that what's happening is that the where() part of the chain is returning an instance of Illuminate\Database\Query\Builder which of course doesn't have a firstOrFail() method. But why is this happening? It should be returning an instance of Eloquent.
This actually seems to be an issue with the version of Laravel. My local dev server was running 4.1.18 and the production 4.1.22. v4.1.22 is causing the error, but when I downgrade to 4.1.18 the error goes away. Is this a known issue in 4.1.22?
use ->get() method at last. $email = Email::with('recipient')->where('token', '=', $data['token'])->firstOrFail()->get();
or
use ->get() method at last. $email = Email::with('recipient')->where('token', '=', $data['token'])->first()->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community