php - How to passing two id's from the URL to the controller in laravel
273
I'm sorry I can't pass two ids from the URL to the controller give me an error Undefined variable: id
the problem in the user id in the controller
My Route:
Route::get('addappotouser/{id}/{dates_id}','[email protected]');
Href :
<a href="{{url('addappotouser' . '/'. $usersss->id .'/'. $date->id)}}" value="" class="btn btn-success btn-mini deleteRecord" type="submit">{{$date->Dates}}</a>
Controller:
public function create( $id , $dates_id)
{
$bookappoitm=DB::table('times')
->where('times.Dates_id',$dates_id)
// ->where('times.Dates_id',1)
->whereNoTIn('times.id',function($query){
$query->select('times_id')->from('bookappoitments')
->where('users_id',$id)
->get();
})
->get();
$datee=Dates::find($dates_id)
->where('dates.id',$dates_id)
->select('dates.*')
->first();
$userss=User::find($id)
->where('id',$id)
->select('users.*')
->first();
return view('admin.Managers.addappotouser', compact('bookappoitm','datee','userss'));
URL:
http://127.0.0.1:8000/addappotouser/1/1
Answer
Solution:
Update your code with this you need to use
$id
like thisAnswer
Solution:
You need pass the parameters as array, see https://laravel.com/docs/5.6/helpers#method-route,
Answer
Solution:
Change the line as below: