Passing multiple parameters to controller in Laravel 5

后端 未结 4 1366
有刺的猬
有刺的猬 2020-12-10 01:03

In my application, a user has the ability to remind another user about an event invitation. To do that, I need to pass both the IDs of the event, and of the user to be invit

相关标签:
4条回答
  • 2020-12-10 01:26

    Go to your controller and write code like following:

    public function passData()
    {
    
        $comboCoder=['Bappy','Sanjid','Rana','Tuhin'];
        $ffi=['Faisal','Sanjid','Babul','Quiyum','Tusar','Fahim'];
        $classRoom=['Sanjid','Tamanna','Liza'];
        return view('hyper.passData',compact('comboCoder','ffi','classRoom'));
    }
    
    /*
    Again, in View part use:
    (passData.blade.php)
    */
    
    <u>Combocoder:</u>
    
    @foreach($comboCoder as $c)
    {{$c}}<br>
    @endforeach
    
    <u>FFI</u>
    
    @foreach($ffi as $f)
    
    {{$f}}<br>
    @endforeach
    
    <u>Class Room </u>
    
    @foreach($classRoom as $cr)
    
    {{$cr}}<br>
    @endforeach
    
    0 讨论(0)
  • 2020-12-10 01:31

    When you define this route:

    Route::get('events/{id}/remind', [
    'as' => 'remindHelper', 'uses' => 'EventsController@remindHelper']);
    

    You are saying that a single URI argument will be passed to the method.

    Try passing the two arguments, like:

    Route::get('events/{event}/remind/{user}', [
    'as' => 'remindHelper', 'uses' => 'EventsController@remindHelper']);
    

    View:

    route('remindHelper',['event'=>$eventId,'user'=>$userId]);
    
    0 讨论(0)
  • 2020-12-10 01:39
    Route::get('/details/{id}/{id1}/{id2}', 'HomeController@SearchDetails');
    
    //pass data like the below code
    
    <a href="{{url("/details/{$orga_list->dcode}/{$orga_list->dname}/{$GroupHead}")}}" 
    target="_blank" > Details </a>
    
    //controller write like the below code
    
    public function SearchDetails($id, $searchtext,$grp_searchtext)  
    {
    // get data like the below code
    
    $data['searchtext'] = $searchtext;
    $data['grp_searchtext'] = $grp_searchtext;
    $data['id_is'] = $id;
    }
    
    0 讨论(0)
  • 2020-12-10 01:48

    Route :

    Route::get('warden/building/{buildingId}/employee/{employeeId}',[
        'uses'=>'WardenController@deleteWarden',
        'as'=>'delete-warden'
    ]);
    

    View :

    <a href="{{route('delete-building',[$building->id])}}"></a>
    

    Controller:

    public function deleteWarden($buildingId,$employeeId){
        $building = Building::find($buildingId);
        $building->employees()->detach($employeeId);
        return redirect('warden/assign/'.$buildingId)->with('message','Warden Detached successfully');
    
    }
    
    0 讨论(0)
提交回复
热议问题