I am new to laravel and building my first project using it. I want to query two tables (Cases and Detail) using orWhere() function. Please tell me the changes I need to make in my existing code.
Controller.php
$key = trim($request->get('q'));
$cases = Cases::query()
->where('cnic', "$key")
->orWhere('eventDate', "$key")
->get();
return view('adminHome',['user' => $cases ]);
The field eventDate exists in the Detail Model.
adminhome.blade
<form action="/search" method="GET" role="search">
<input type="number" name="q" placeholder="Search CNIC...">
<input type="date" name="q" placeholder="Search CNIC..." ">
<input type="Submit" name="Search" value="Search">
{{ csrf_field() }}
</form>