jake balba jake balba - 3 days ago 5
PHP Question

How to add multiple where clause on Eloquent ORM Laravel?

Having a hard time here trying to retrieve specific records where I need the ID and the Date to match, here is my code:

$testq= DB::table('attendances')->where('user_id', '=', $userinput && 'logon', '=', $newdate)->get();

Answer

Just add one more where.

$testq= DB::table('attendances')
    ->where('user_id', '=', $userinput)
    ->where('logon', '=', $newdate)
    ->get();

http://laravel.com/api/4.2/Illuminate/Database/Eloquent/Builder.html#method_where

$this where(string $column, string $operator = null, mixed $value = null, string $boolean = 'and')

Add a basic where clause to the query.

Comments