简体   繁体   中英

pass value to route and then controller

this is my view

<a href="{{URL::route('audit_crawling')}}"class="clear active"> </a>

and i want to pass value to route, value is in $id variable

  {{URL::route('audit_crawling'.$id)}}

and i want to get this value here and pass to controller

Route::get('/dashboard',[
    'as'=>'audit_crawling',
    'uses'=>'ProjectController@audit_crawling'
]);

and this is my controller code

 function audit_crawling($id)
     {
     data=['id'=>$id];
    return view('user.project.dashboard',$data);
    }

To pass data to controller use:

Route:

Route::get('/dashboard/{id}',[
    'as'=>'audit_crawling',
    'uses'=>'ProjectController@audit_crawling'
]);

Controller

    public function audit_crawling($id) {
    echo $id;
}

Link :

<a href="{{route('audit_crawling',$id)}}" class="clear active"> </a>

or

<a href="{{url('dashboard/'.$id)}}" class="clear active"> </a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM