Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Laravel 5上添加警报?_Php_Laravel_Laravel 5 - Fatal编程技术网

Php 如何在Laravel 5上添加警报?

Php 如何在Laravel 5上添加警报?,php,laravel,laravel-5,Php,Laravel,Laravel 5,我有一个函数,其中: 单击名为“hapus”的链接后,相关数据将被删除,我希望弹出一个警报,显示数据已被删除。 *对不起,我英语不好 *从技术上讲,哈布斯意味着毁灭 这是代码: public function hapus(Request $request, $id) { DB::table('kelompok') ->where('id', $id) ->delete(); return redirect()->back

我有一个函数,其中:
单击名为
“hapus”
的链接后,相关数据将被删除,我希望弹出一个警报,显示数据已被删除。

*对不起,我英语不好

*从技术上讲,哈布斯意味着毁灭

这是代码:

public function hapus(Request $request, $id) { DB::table('kelompok') ->where('id', $id) ->delete(); return redirect()->back(); } 公共功能hapus(请求$Request,$id) { DB::table('kelompok') ->其中('id',$id) ->删除(); 返回重定向()->back(); } 在控制器中使用

 function hapus(Request $request, $id)
        {
            DB::table('kelompok')
            ->where('id', $id)
            ->delete();
            return redirect()->back()->with('alert', 'Deleted!');
        }
在刀片模板中,从控制器重定向后检索
会话

@if (session('alert'))
    <div class="alert alert-success">
        {{ session('alert') }}
    </div>
@endif
@if(会话('alert'))
{{session('alert')}
@恩迪夫
扩展@pbowned's, 您还可以在blade视图中使用javascript
警报框
,以显示flash会话/消息

例如:

<script>
  var msg = '{{Session::get('alert')}}';
  var exist = '{{Session::has('alert')}}';
  if(exist){
    alert(msg);
  }
</script>

var msg='{{Session::get('alert')}}';
var exist='{Session::has('alert')}}';
如果(存在){
警报(msg);
}
希望它能帮助=)

with()
witherror()
这些是我们可以使用的一些方法。