I'm trying to add laravel-toast using his code https://github.com/Grimthorr/laravel-toast
I wrote like this (error case)
if ($validator->fails()) {
return redirect('/')->with($notification);
->withInput()
->withErrors($validator)
// I add this below line but didn't work
->withErrors($notification = array(
'message' => 'error' ,
'alert-type' => 'error'));
}
And this is success case
$books = new Book;
$books->item_name = $request->item_name;
$books->item_number = $request->item_number;
$books->save();
$notification = array(
'message' => 'success' ,
'alert-type' => 'success'
);
return redirect('/')->with($notification);
Here is my blade file
<script>
@if(Session::has('message'))
var type=""
switch(type){
case 'error':
toaster error("");
break;
case 'success':
toaster success("");
break;
}
@endif
</script>
Tost didn't show up I thought Controller code is looks wrong... Could somebody correct my code please.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire