I`m new to the laravel 5.4.what i want to do is when i press the See Here green color button,All the details need to be shown in new view called seedetails.blade.php according to relevant Trainee_ID.for an example if i press MOB/TR 1741 See details button all the data in the database need to shown only according to that ID. see the interface .
relevant view for that view.
<table class="table table-striped">
<thead>
<th>Trainee ID</th>
<th>Name with Initials</th>
<th>Working Division</th>
<th>Starting Date</th>
<th>Ending Date</th>
<th>See All the Details<</th>
</thead>
<tbody>
@foreach($items as $item)
<tr>
<td>{{ $item->trainee_id }}</td>
<td>{{ $item->name_with_initials }}</td>
<td>{{ $item->trainee_division }}</td>
<td>{{ $item->start_date }}</td>
<td>{{ $item->end_date }}</td>
<td>
<a class="btn btn-success" href="Seedetails/{{ $item->traninee_id }}">See Here</a>
</td>
</tr>
@endforeach
</tbody>
</table>
Here is the necessary controller for retrive data according to trainee_id
public function user_details($traninee_id)
{
$trainee_details= registerdetails::where('id','=',$traninee_id)->get()->first();
return view('registeredusers.seedetails', compact('trainee_details'));
}
Here is the seedetails.blade.php which should retrieve the data and shown.which is linked to above view`s see button ,see the code.
`<div class="panel panel-default">
<div class="panel-body">
<div class="col-md-6 col-md-offset-3">
<table class="table table-bordered">
<tbody>
<tr>
<td>Full Name</td>
<td>{{ $item->full_name }}</td>
</tr>
<tr>
<td>Nic No</td>
<td>{{ $item->nic_no }}</td>
</tr>
<tr>
<td>Date Of Birth</td>
<td>{{ $item->date_of_birth }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
Here is the Route for that view
Route::get('Seedetails/{id}', 'UserRegisterController@user_details');
Then this is the error now um getting when i press the See details button.
you are making a big mistake, try to pass the name of the column you have in the database to the route, so that you dont make a mistake, anyways try this in the html
<td>
<a class="btn btn-success" href="Seedetails/{{ $item->trainee_id }}">See Here</a>
</td>
and if possible rename your route to
Route::get('Seedetails/{trainee_id?}', 'UserRegisterController@user_details')->where('trainee_id', '(.*)');;
You may have to use URL Helper
<a class="btn btn-success" href="{{ URL::to('Seedetails/'.$item->traninee_id) }}">See Here</a>
OR alternatively
<a class="btn btn-success" href="{{ url('Seedetails/'.$item->traninee_id) }}">See Here</a>
for more helpers refer to https://laravel.com/docs/5.4/helpers#urls
You can try this using regular expression. Because in trainee id contained slash : May be You have mistaken the correct spelling of trainee id in url.
<a class="btn btn-success" href="{{url('/',[$item->trainee_id])}}">See Here</a>
use this route
Route::any('{id}','UserRegisterController@user_details')->where('id', '(.*)');