laravel - 如何在 href 中传递 id 以使用 laravel 在下一页显示详细信息
问题描述
实际上,我正在获取所有职位详细信息,但是我需要在单击数据表中职位列表中的按钮时显示特定职位的详细信息。
demo1.blade.php
@foreach ($jobposts as $jobpost)
<tr>
<td>{{ $jobpost->job_code }}</td>
<td>{{ $jobpost->position }}</td>
<td>{{ $jobpost->department }}</td>
<td>{{ $jobpost->location }}</td>
<td>{{ $jobpost->employement_type }}</td>
<td>{{ $jobpost->created_at }}</td>
<td><a href="/demo2"><button class="btn btn-default btn-
apply">Apply</button></a></td>
</tr>
@endforeach
demo2.blade.php
@foreach ($jobposts as $jobpost)
<h4 class="heading color">Basic Eligibility Criteria: {{ $jobpost->position }}</h4>
<hr>
<p><strong>Job Code:</strong> {{ $jobpost->job_code }} </p>
<p><strong>Job Discription:</strong> {{ $jobpost->job_discription }} </p>
<p><strong>Skills Required:</strong> {{ $jobpost->skills_required }} </p>
<p><strong>Eligibility:</strong> {{ $jobpost->eligibility }} </p>
<p><strong>Package:</strong> {{ $jobpost->package }} </p>
<p><strong>Department:</strong> {{ $jobpost->department }} </p>
<p><strong>Location:</strong> {{ $jobpost->location }} </p>
<p><strong>Employement Type:</strong> {{ $jobpost->employement_type }} </p>
<p><strong>Note:</strong> {{ $jobpost->detail }} </p>
@endforeach
演示控制器.php
public function index()
{
$jobposts = DB::table('jobposts')->select('job_code','position','department','location','employement_type','created_at')->get();
return view('home.demo1')->with('jobposts', $jobposts);
}
public function jobcode()
{
$jobposts = DB::table('jobposts')->get();
return view('home.demo2')->with('jobposts', $jobposts);
}
网页.php
Route::get('/demo1', 'CareerController@index');
Route::get('/demo2', 'CareerController@jobcode');
解决方案
<td><a href="/url/{{ $id }}"></a></td>
在 web.php 中
Route::get('/demo/{id}', 'DemoController@index');
在 DemoController.php
public function index($id)
{
// Your code
}
推荐阅读
- php - 将控制器中的数据显示为列和行
- angularjs - 如何将 JIRA 与我们自己的 AngularJS 应用程序集成
- sql-server - 如果某些参数未传递给过程,则参数化存储过程会绕过左连接
- python - 如何将 np.poly1d 对象转换为字符串值?
- c++ - 如何仅旋转特定对象而不影响opengl中的其他对象?
- go - 抑制从包生成的错误消息
- python - 如何使用用户定义的消息从 python pandas 导出数据
- c++ - C ++以正确的方式在堆上声明一个静态连续多维数组
- swift - 如何创建图像数组,并在 Swift 中使用 draw() 将它们绘制出来?
- http - HTTP KeepAlive 可以作为 TCP KeepAlive 的替代品吗?