laravel select where and where condition
laravel select where and where condition
$this->where(email, $email)->where(password, $password)
is returning a Builder object which you could use to append more where filters etc.
To get the result you need:
$userRecord = $this->where(email, $email)->where(password, $password)->first();
You either need to use first()
or get()
to fetch the results :
$userRecord = $this->where(email, $email)->where(password, $password)->first();
You most likely need to use first()
as you want only one result returned.
If the record isnt found null
will be returned. If you are building this query from inside an Eloquent class you could use self
.
for example :
$userRecord = self::where(email, $email)->where(password, $password)->first();
More info here
laravel select where and where condition
$userRecord = Model::where([[email,=,$email],[password,=, $password]])->first();
or
$userRecord = self::where([[email,=,$email],[password,=, $password]])->first();
I`
think this condition is better then 2 where. Its
where condition array in array of where conditions;