I am trying to make a query using Eloquent Model in Laravel.
My original query does not work
Query1::where('Course_ID', '=', $request->FLA)
->where('Date', '=', Carbon::today())
I would like the query to include both inside of a single WHERE, akin to:
Query1::where('Course_ID', '=', $request->FLA && 'Date', '=', Carbon::today())
Is this possible?
>Solution :
You can use:
Query1::where([
'Course_ID' => $request->FLA,
'Date' => Carbon::today()
]);
It will create the following SQL query:
SELECT * FROM tablename WHERE Course_ID = ? AND Date = ?
But your approach, using two ‘where’s will have the same output