2017-02-17 28 views
0

我有User,它有很多Post s。
波紋管User編輯表格我想顯示相關的Post的網格。在laravel揹包的編輯窗體中添加一個網格

以下功能會帶來相關帖子。 如何將其組合在上/內/下波形編輯User的形式?

我知道這個功能會起作用,只是不知道如何組合它。

// user crud controller 

    public function getUserRlatedPosts($user_id) 
    { 

     $crud = new CrudPanel(); 
     $crud->addClause('where', 'user_id', '=', $user_id); 
     $crud->setModel("post"); 
     $crud->setEntityNameStrings("post","posts"); 
     $crud->enableAjaxTable(); 

     $this->data['crud'] = $crud; 
     $this->data['title'] = ucfirst($this->crud->entity_name_plural); 
     if (! $this->data['crud']->ajaxTable()) { 
      $this->data['entries'] = $this->data['crud']->getEntries(); 
     } 
     return view('crud::list', $this->data); 
    } 

回答

1

在揹包\ CRUD 3.2.x中您可以使用自定義視圖以下方法:

$this->crud->setShowView('your-view'); 
$this->crud->setEditView('your-view'); 
$this->crud->setCreateView('your-view'); 
$this->crud->setListView('your-view'); 
$this->crud->setReorderView('your-view'); 
$this->crud->setRevisionsView('your-view'); 
$this->crud->setRevisionsTimelineView('your-view'); 
$this->crud->setDetailsRowView('your-view'); 

,並指定視圖,其中還包括形式。

+0

謝謝,我已經知道了。但我不明白如何才能實現?我應該將供應商的視圖移到我的視圖文件夾並更改它嗎?你能提供一些解釋嗎?也許僞代碼? 我沒有看到任何接近於文檔或git問題的內容。再次感謝 – Shazam

+0

嗨Shazam。不,只需在/ resources /中創建一個/ vendor/backpack/crud文件夾即可。這將做到這一點。然後放置一個你想在那裏定製的文件。 – tabacitu

相關問題