Reputation: 43
Controller File:
$validatedData = $request->validate([
'type' => 'required|string|max:255',
]);
$type_data = new Type();
$type_detial = $type_data->add_type($request);
session()->flash('type_create', 'Type Created Successfully!');
return redirect('types/list');
Blade File:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>List</h1>
</body>
</html>
Web.php:
Route::resource('types', 'TypeController');
Insert data in Database than not redirect in list page. Error given is
Sorry, the page you are looking for could not be found.
I create a list.blade.php
file.
Upvotes: 1
Views: 141
Reputation: 124
Please change return redirect('types/list');
to return view('list');
$validatedData = $request->validate([
'type' => 'required|string|max:255',
]);
$type_data = new Type();
$type_detial = $type_data->add_type($request);
session()->flash('type_create', 'Type Created Successfully!');
return view('list');
OR
if you don't want to change anything in controller than add this route in route file
Route::get('types/list', function(){
return view('list');
});
Upvotes: 3