Laravel在重命名页面后显示空白页



我将'cluster'文件夹中的index.blade.php文件重命名为overview.blade.php突然间cluster/overview显示了一个空白页。我重命名了指向该页面的所有其他方法,因此我不确定这里出了什么问题。我认为这与重命名索引有关

编辑:添加了相关代码

视图

@extends('layouts.app')
@include('modal')
@section('content')
<body>
<div class="container">
<div class="row">
<div class="col-12">
<button class="button -dark center">
<a href="/home" class="previous round" style="color: white">&#8249;  Home</a>
</button>
<a href="/cluster/create">
<button type="submit"  class="button -green center float-right">Voeg cluster toe</button>
</a>
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col"><strong>Cluster naam</strong></th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
<tbody>
@foreach($departments as $department)
<tr>
<form action="{{route('deletecluster', $department->id)}}" method="post" id="submit-button">
<td>{{$department->name}}</td>
@csrf
<td><a href="{{url('cluster/edit/' . $department->id)}}"><button  type="button" class="btn btn-info" data-toggle="modal" data-target="#registration">Bewerken</button></a></td>
<td><button class="btn btn-danger" type="submit">Verwijderen</button></td>
</form>
</tr>
@endforeach
</tbody>
</table >
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#submit-button').on('submit', function(e){
$('#registration').modal('show');
e.preventDefault();
});
});
</script>
</body>
@endsection

路由

Route::get('/', function () {
return view('auth/login');
});
Route::resource('event', 'EventController');
Route::resource('cluster', 'ClusterController');
Route::get('calendar', 'EventController@calendar');
Route::get('export', 'EventController@export');
Route::get('user/create', 'UserController@create');
Route::get('user/edit/{id}', 'UserController@edit');
Route::get('cluster/edit/{id}', 'ClusterController@edit');
Route::get('user/settings', 'UserController@settings')->name('settings');
Route::post('user/store', 'UserController@store');
Route::post('user/employeeStore', 'UserController@employeeStore');
Route::post('user/store_settings', 'UserController@settingsStore');
Route::post('user/addShift', 'UserController@addShift');
Route::post('user/togglemail', 'UserController@toggleMail');
Route::get('user/overview', 'UserController@overview');
Route::get('cluster/overview', 'ClusterController@overview')->name('overview');
Route::post('user/delete{id}', 'UserController@deleteUser')->name('deleteuser');
Route::post('cluster/delete{id}','ClusterController@deleteCluster')->name('deletecluster');
Route::post('event/store', 'EventController@store');
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
//Route::get('laravel-send-email', 'EmailController@sendMail');
Route::get('user/changepassword', 'UserController@changePassword');
Route::post('user/updatepassword', 'UserController@updatePassword')->name('updatepassword');

控制器

class ClusterController extends Controller
{
/**
* Display a listing of the resource.
*
* @return IlluminateHttpResponse
*/
public function overview()
{
$departments = Department::all();
return view ('cluster.overview')->with('departments', $departments);
}
/**
* Show the form for creating a new resource.
*
* @return IlluminateHttpResponse
*/
public function create()
{
$shift_types = shift_type::all();
return view('cluster.create')->with('shift_types', $shift_types);
}

/**
* Store a newly created resource in storage.
*
* @param  IlluminateHttpRequest  $request
* @return IlluminateHttpResponse
*/
public function store(Request $request)
{
$department = new Department();
$department->name = $request->input('clustername');
$department->save();
$typeArray = explode(',', $request->input('types'));
foreach($typeArray as $type) {
$shift_type = new ShiftType();
$shift_type ->shift_name = $type;
$shift_type->save();
$department_shift_type = new DepartmentShiftType();
$department_shift_type->department_id = $department->id;
$department_shift_type->shift_type_id =  $shift_type->id;
$department_shift_type->save();
}
return $department->id;
}

/**
* Display the specified resource.
*
* @param  int  $id
* @return IlluminateHttpResponse
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param  int  $id
* @return IlluminateHttpResponse
*/
public function edit($id)
{
$departmentshift = DepartmentShiftType::findOrFail($id);
$departmentshifts = DepartmentShiftType::all();
$shifts = ShiftType::all();
$shift = ShiftType::findOrFail($id);
$shift_id = $departmentshift->shift_type_id;
$department = Department::findOrFail($id);
return view('cluster.edit')->with('department', $department)->with('departmentshift', $departmentshift)->with('shift_id', $shift_id)->with('departmentshifts', $departmentshifts)->with('shifts', $shifts)->with('shift', $shift    );
}
/**
* Update the specified resource in storage.
*
* @param  IlluminateHttpRequest  $request
* @param  int  $id
* @return IlluminateHttpResponse
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param  int  $id
* @return IlluminateHttpResponse
*/
public function deleteCluster($id)
{
$department = Department::findOrFail($id);
$department->delete();
return redirect('cluster.overview');
}
public function destroy($id)
{
//
}
}

移动此行:

Route::get('cluster/overview', 'ClusterController@overview')->name('overview');

在这上面:

Route::resource('cluster', 'ClusterController');

Laravel认为你正在尝试调用这条路线:/cluster/{cluster}

public function show($id)
{
//
}

您可以通过在show方法中添加一些返回值来确认这一点

public function show($id)
{
dd('foobar');
}

最新更新