新的Laravel路线不起作用

时间:2018-04-16 07:15:30

标签: php laravel routes xampp

我有一个问题,laravel中的新路线无法正常工作,网址显示正确的路线,但几乎就好像它没有到达我的路线网页文件每次只返回页面未找到。 / p>

我试过了: 使用命名路由, 将功能移动到不同的控制器, 清除路由缓存, 清除应用缓存 dump-auto load , 确保 AllowOverride 设置为全部

Web.php:

    <?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

/*
|--------------------------------------------------------------------------
| Courses
|--------------------------------------------------------------------------
*/
Route::get('/courses', 'CourseController@index');
Route::get('/courses/create', 'CourseController@create');
Route::get('/courses/{course}', 'CourseController@show');
Route::get('/courses/{course}/edit', 'CourseController@edit');
Route::post('/courses', 'CourseController@store');
Route::patch('/courses/{course}', 'CourseController@update');
Route::delete('/courses/{course}', 'CourseController@destroy')->name('course-delete');

Route::get('/courses/statistics', 'CourseController@statistics');

/*
|--------------------------------------------------------------------------
| First Aid
|--------------------------------------------------------------------------
*/
Route::get('/section/{section}', 'SectionController@show');


/*
|--------------------------------------------------------------------------
| First Aid
|--------------------------------------------------------------------------
*/
Route::get('/progress', 'UserProgressController@index');
Route::get('/progress/create', 'UserProgressController@create');
Route::get('/progress/{section}', 'UserProgressController@show');
Route::get('/progress/formativeresults', 'UserProgressController@formativeresults');
//Route::get('/progress/coursestatistics', 'UserProgressController@coursestatistics');
//Route::get('/progress/{progress}/edit', 'UserProgressController@edit');
Route::post('/progress', 'UserProgressController@store');
//Route::patch('/progress/{progress}', 'UserProgressController@update');
//Route::delete('/progress/{progress}', 'UserProgressController@destroy')->name('progress-delete');

控制器:

public function statistics()
    {
        dd('Test');
       return view('coursestatistics');
    }

查看文件名: coursestatistics.blade.php 文件结构视图/ coursestatistics

链接到页面:

<a class="navbar-brand" href="/courses/statistics">
   {{ __('Statistics') }}
</a>

有谁能告诉我可能导致路线不起作用的原因?

2 个答案:

答案 0 :(得分:4)

我有同样的问题,用配置做了所有这些魔法,什么也没有.. 解决方法:运行:php artisan route:clear

答案 1 :(得分:3)

尝试放置

Route::get('/courses/statistics', 'CourseController@statistics');

低于此特定路线代码

Route::get('/courses/create', 'CourseController@create');

laravel路由的一般规则是在相关的通配符路由之前放置特定路由。链接here