I can't return a toast error message. Where am I making a mistake? Message returns when successful.
My code is as follows:
public function store(Request $request)
{
$validated = $request->validate([
'category_name' => 'required|unique:categories|max:50',
]);
$data = array();
$data['category_name'] = $request->category_name;
$save = DB::table('categories')->insert($data);
if ($save) {
Toastr::success('Post Successfully Saved :)', 'Success');
return redirect()->route('admin.category');
} else {
Toastr::error('Error :)', 'Error');
return redirect()->route('admin.category');
}
}