Php blade page正在显示任何内容

Php blade page正在显示任何内容,php,laravel,Php,Laravel,我试图制作一个索引页,但无论出于什么原因,它都没有显示任何内容。 这是我的路线 Route::get('/home', 'HomeController@index')->name('home'); Route::resource('student','StudentsController'); Route::resource('student/absense','AbsensesController'); 正如你所看到的,我正在使用资源,所以我的路线已经生成了 这是我的控制器 publi

我试图制作一个索引页,但无论出于什么原因,它都没有显示任何内容。 这是我的路线

Route::get('/home', 'HomeController@index')->name('home');
Route::resource('student','StudentsController');
Route::resource('student/absense','AbsensesController');
正如你所看到的,我正在使用资源,所以我的路线已经生成了

这是我的控制器

public function index()
    {
        return view('student.absense.index');

            }

    /**
我的观点是:

@extends('layouts.app')

@section('content')

<table class="table ">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">Prenome</th>
      <th scope="col">Nom</th>
      <th scope="col">Niveau</th>
      <th scope="col">group</th>
      <th scope="col">Payment date End</th>
      <th scope="col"> More options</th>
    </tr>
  </thead>
  <tbody>



    <tr>

      <th scope="row"></th>
    </tr>

</tbody>

</table>
@endsection
我得到的页面是空的,没有任何错误。知道为什么吗

顺便说一句,索引在absense文件夹中,absense文件夹在student文件夹中。

对于此语句:

  return view('student.absense.test');
您正在尝试加载名为test的absense文件夹中的文件,但此处:

Btw **index** is inside absense folder and absense folder is inside student folder.
您说您在该文件夹中有一个名为index的文件,而不是test。我想这就是为什么你没有得到你想要的


将absense文件夹中的索引文件重命名为test,或将您在索引函数中声明的测试文件从test重命名为index。

如果试图查找ID为absense的学生,但未找到该学生,请将路由更改为

Route::get('/home','HomeController@index')->名称('home');
路线::get('学生/缺席','AbsensesController@index');
路由::资源('student'、'StudentsController');
给定如下
AbsensesController


您的路线顺序存在冲突:

你正在添加

Route::resource('student','StudentsController');
Route::resource('student/absense','AbsensesController');
资源将添加以下显示路线:

student/{student}
那么你是在添加

Route::resource('student','StudentsController');
Route::resource('student/absense','AbsensesController');
资源将添加以下索引路由:

student/absense
但是因为
student
路由在
student/absense
路由之前,所以您永远不会访问索引路由,而是
student/{student}
,因为
{student}
通配符捕获
student/absense
并输入
StudentController@show
路线

切换路由定义可以解决以下问题:

Route::resource('student/absense','AbsensesController');
Route::resource('student','StudentsController');
或者,您可以添加连字符,以避免发生冲突:

Route::resource('student','StudentsController');
Route::resource('student-absense','AbsensesController');

我假设您在
web.php
文件中有这些路由,而不是在
api.php
或其他文件中?看起来您的路由出了问题。尝试不使用
::资源
,并查看是否使用
::get
修复它。其他路线有效吗?我在web.php上使用。是的,这条路线有点问题,我看不出来。即使我改了,它还是不起作用。这是个错误。当我在这里复制这段代码时,我并没有改变,但实际上我使用的是索引,我只是想用另一个视图试试,这样我就可以找出为什么我的rout不起作用了。这是一个错误。当我在这里复制这段代码时,我并没有改变,但我实际上在使用索引,我只是想用另一个视图尝试一下,这样我就可以找出为什么我的路由不起作用。再次更新!我就是这样做的;(您使用的是
resource
route,而不是
get
routeeyes。您现在的工作是正确的,因为php通常从下到上阅读。非常感谢您