如何使用HREF中的ID通过Laravel在NextPage上显示详细信息



实际上我正在获取所有位置详细信息,但是我需要在单击数据表中的位置列表中单击一个按钮时显示特定位置的详细信息。

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

democontroller.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);
}

web.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
}

最新更新