【发布时间】:2020-08-05 20:09:27
【问题描述】:
我正在开发 Laravel 5,我已经为所有页面设置了路由。我有一个仪表板,其中包含某些图标,单击这些图标会重定向到不同的页面。现在,这个特定的图标“Total Applications”在单击时不会重定向到与之关联的页面,即total.blade.php,而是重定向到另一个页面candidate.blade.php。
我是 Laravel 的新手。我希望当我点击“Total Applications”页面时,它应该重定向到为其指定的页面。
我正在分享以下代码:
dashboard.blade.php 文件:
<div class="col-md-4">
<div class="single-dashboard-link card card-default p-3 text-center" onclick="location.href='{{route('employers.total')}}'">
<i class="fa fa-file-text font30"></i>
<h6>
{{ $user->employerJobApplications()->count() }} Total
</h6>
<p>
Applications
</p>
</div>
</div>
包含两个页面的路由的路由文件:-
Route::get('/total-applications', 'Frontend\EmployersController@totalApplications')->name('employers.total');
Route::get('/{status}', 'Frontend\EmployersController@candidatesDisplay')->name('employers.candidate');
我的控制器包含 Total Applications 页面的逻辑:-
public function totalApplications() {
if (!Auth::check()) {
session()->flash('error', 'Sorry !! You are not an authenticated Employer !!');
return back();
}
$user = Auth::user();
$user_id = $user->id;
$applicant = JobActivity::where('user_id',$user_id)->get();
return view('frontend.pages.employers.total', compact('user', 'applicant'));
}
【问题讨论】:
-
(除此之外:要在 Markdown 中创建分段符 (
<p>),只需使用两次 Enter。这里的帖子中不需要<br>)。
标签: php laravel laravel-5 eloquent