Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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
Mysql Laravel更新表值_Mysql_Laravel - Fatal编程技术网

Mysql Laravel更新表值

Mysql Laravel更新表值,mysql,laravel,Mysql,Laravel,我在laravel5.4工作。在我的查看页面中,我有一个包含状态的列表。如果通知的是禁用,我想通过单击按钮使其启用。请告诉我最好的方法 enter code here @foreach($publishers as $publisher) <ul class="list-group"> @if($publisher->pivot->is_notified===1) <li class="list-group-item li

我在laravel5.4工作。在我的查看页面中,我有一个包含状态的列表。如果通知的是禁用,我想通过单击按钮使其启用。请告诉我最好的方法

enter code here

 @foreach($publishers as $publisher)
  <ul class="list-group">
       @if($publisher->pivot->is_notified===1)
           <li class="list-group-item list-group-item-success">
                {{$publisher->name}}<span class="pull-right">Notified</span>
            </li>
        @else
             <li class="list-group-item list-group-item-danger">
            {{$publisher->name}}<span class="pull-right">not notified</span>
             </li>
        @endif
    </ul>
  @endforeach
在此处输入代码
@foreach($publisher作为$publisher)
    @如果($publisher->pivot->已通知===1)
  • {{$publisher->name}已通知
  • @否则
  • {{$publisher->name}}未通知
  • @恩迪夫
@endforeach
1)创建一个按钮,该按钮链接到一个路由,并将要通知的发布者id作为参数

<a href="{{ url('/publisher/'.$publisher->id) }}">
   <button">View Slip</button>
</a>
3) 在控制器(即PublishersController.php)中,获取id

public function enable ($id) {

   $publisher = Plusher::where('id', $id)->first();
   $publisher -> is_notified = "enable"
   $publisher -> save();

}

使用ajax怎么样?代码在哪里?这是我在laravel的第一个项目。我有一列是活动的,禁用时为零,启用时为一。我想要最好的方法,我只需要使用foreach循环并打印值
public function enable ($id) {

   $publisher = Plusher::where('id', $id)->first();
   $publisher -> is_notified = "enable"
   $publisher -> save();

}