我正在开发 Laravel 5,并且已经为所有页面设置了路由。我有一个仪表板,其中包含某些图标,单击这些图标会重定向到不同的页面。现在,这个特定的图标“Total Applications”在单击时不会重定向到与其关联的页面,即total.blade.php,而是重定向到另一个页面candidate.blade.php。我是 Laravel 的新手。我希望当我单击“应用程序总数”页面时,它应该重定向到为其指定的页面。我分享以下代码:仪表板.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');我的控制器包含“总应用程序”页面的逻辑:-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'));}
1 回答

一只萌萌小番薯
TA贡献1795条经验 获得超7个赞
好的。让我们解释一下
Route::get('/{status}', 'Frontend\EmployersController@candidatesDisplay')->name('employers.candidate');
该路由接受一个参数,status
例如
example.com/pending example.com/active example.com/suspended
total-applications
它可以是参数吗?是的,这可能是为什么不所以路线将是
example.com/total-applications
哪个重定向到Frontend\EmployersController@candidatesDisplay
哪个导致candidate.blade.php
不能通过total.blade.php
在前面添加任何前缀来解决它{status}
请注意,您调用的任何端点都将落入该路由/{status}
,因为该路由接受您将到达的任何路径。
- 1 回答
- 0 关注
- 84 浏览
添加回答
举报
0/150
提交
取消