I'm just confused about my code. But I really thought that my code is correct. I'm trying to use with() method in Laravel 5.1 and then return to a view, then the sweet alert appears if the session that has been set is exists. Please see my code below:
PageController.php
return redirect()->route('list.view')->with('sweetalert', 'List has been created!');
view.blade.php
@extends('layout.master')
@section('container')
@foreach($lists as $list)
<li></li>
@endforeach
@stop
master.blade.php
<div class="container">
// some markup here...
</div>
@if(Session::has('sweet'))
<script>
swal('Success!', '', 'success');
</script>
@endif
I only want it to appear once, but if I try to click the back button, the message appears again. I have also tried the ff. code but nothings change:
@if(Session::has('sweet'))
<script>
swal('Success!', '', 'success');
</script>
<?php Session::forget('sweet'); ?>
@endif
Little help here?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2td2P3d
via IFTTT
Aucun commentaire:
Enregistrer un commentaire