2016-09-26 77 views
0

我需要更新我的權限表生通過edit.blade.php文件我怎麼能在Laravel更新我的表生5.2

edit.blade.php 
    @extends('layouts.app') 
    @section('content') 


    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> 
    <h1 class="page-header"> Edit Project</h1> 
    @if($permission) 
    @include('layouts.partials.alerts') 
<div class="col-lg-6"> 
     <form class="form-vertical" role="form" method="post" action=""> 
      <div class="form-group{{ $errors->has('status') ? ' has-error' : '' }}"> 
       <label for="status" class="control-label">Choose Status</label> 
       <select name="status" id="status"> 
        <option value="{!! $permission->status !!}">{!! $permission->status !!}</option> 
       {{ getStatus($permission->status) }} 
       </select> 
       </div> 
       </form> 
       </div> 
@endif 
</div> 


@stop 

我的控制器方法是這樣的

public function edit($id) 
    { 
     $permission = Permission::find($id); 
     return view('collaborators.edit')->withPermission($permission); 
    } 

但是當我點擊編輯按鈕edit.blade.php它只是顯示

Edit Project 

無法看到萬畝下拉選擇狀態我的權限模型是

<?php 

namespace App; 

use Illuminate\Database\Eloquent\Model; 

class Permission extends Model 
{ 
    protected $table = 'permissions'; 


    protected $fillable = ['status','project_id','collaborator_id']; 

    public function scopeProject($query, $id) 
    { 
     return $query->where('project_id', $id); 
    } 



     public function project_collaborator() 
    { 
     return $this->belongsToMany('App\Collaboration','collaborator_id'); 
    } 

    // 
} 

我該如何解決這個問題?

+0

哪裏是你的餐桌? – Borna

+0

你是什麼意思「你的桌子在哪裏?」 – Fernando

+0

你提到「更新我的表原料」 – Borna

回答

-1
<form class="form-vertical" role="form" method="post" action=""> 

在這裏,你必須設定行動=「」也許這個{{/編輯}}這取決於你的路線上

+0

是的,但行動需要形成這個edit.blade.php視圖。首先我有問題不顯示下拉菜單我需要更新? – Fernando

+0

嘗試刪除'@if($ permission)'來找出它爲什麼不顯示並改變這個'' –

+0

當我刪除@if($ permission)時,這個''出現以下錯誤「嘗試獲取非對象的屬性」 – Fernando