Laravel更新表值

时间:2017-03-27 12:22:36

标签: mysql laravel

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

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

1 个答案:

答案 0 :(得分:0)

1)创建一个按钮,该按钮链接到您要作为参数通知的发布商的ID。

num

2)创建路线

var num = Int()

FIRDatabase.database().reference().child("menus/Day1").observeSingleEvent(of: .value, with: {(snap) in

    print(snap)

    if let snapDict = snap.value as? [String:AnyObject]{

        self.num = snapDict["date"] as! Int

        if self.num == 5 {
            print("number is 5")
        else {
            print("number is not 5")
        }
    }
})

3)在您的控制器中,即PublishersController.php,获取id

<a href="{{ url('/publisher/'.$publisher->id) }}">
   <button">View Slip</button>
</a>