简体   繁体   中英

Add get route to table using Form or HTML

I have a class="table table-hover" table and am trying to make it clickable. The table consists of user ID, Name and other attributes. My first attempt was to make the whole row clickable but it took time and I failed to do so. Now I decided to make the user ID clickable by this code :

@foreach($user as $users)

        <tbody>
            <tr>
                <td> {{link_to('home', $title = $users->id)}} </td>
                <td>{{$users->name}}</td>
                <td>{{$users->phone}}</td>
                <td>{{$users->city}}</td>
                <td>{{$users->street}}</td>
                <td>{{$users->national_id}}</td>
                @endforeach

And this is my route

Auth::routes();
Route::group(['middleware'=>'auth'],function () {
Route::get('/home', 'HomeController@index');
Route::Resource('/user', 'UserController');
 });


Route::get('/admin', 'HomeController@adminIndex');

My question is how can I make the id clickable where it should be a GET method to the SHOW function ( public function show($id) ). Meaning user/1

Make a td that contains an anchor in it like:

<td><a href="{{ url('/showdetails').'/'.$users->id }}"></a></td>

here showdetails is defined in the route and call a method of some controller like:

function showDetails(Request $request)  // $request will return $users->id
{
    // your code
}

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