我想制作僅具有關系的表的列表,例如:桌子:命令過程在 ProcessCrudController 中,我想將流程列表視圖替換為僅具有關系(訂單流程)的訂單列表視圖。我嘗試過的解決方案:在 OrderCrudController 中創建新函數return view($this->crud->getListView(), $this->data);然后,addClause使用$request->typeURL該解決方案的問題:不顯示表中的操作行如果我們嘗試刪除 URL,很容易顯示所有查詢我真的想制作僅與訂單相關的流程列表視圖,或者有任何建議/想法來實現這一點嗎?注意:我正在努力解決這個問題,我沒有找到解決方案,請幫助我編輯(添加代碼):訂單Crud控制器:protected function setupListOperation(){ // This is the solution that I described before // $request = request(); // $this->crud->addClause('where', 'user_id', '=', $request->type ?? 1); $this->crud->addColumns([ [ 'name' => 'personal_name', 'label' => 'Name', 'type' => 'text', ], [ 'name' => 'notes', 'label' => 'Catatan', 'type' => 'textarea', ], [ 'name' => 'user_id', 'label' => 'Dibuat oleh', 'type' => 'select', 'entity' => 'user', 'attribute' => 'name', 'model' => 'App\User', ], ]);}ProcessCrudController:protected function setupListOperation(){ CRUD::setFromDb(); // This table should be listing Order's query and that only have a process (already created custom_create_view) // That's why i want to take Order's table and not making new custom_list_view}
1 回答

慕絲7291255
TA貢獻1859條經驗 獲得超6個贊
您不必創建新視圖,只需使用 addClause ... 修改查詢結果即可。
在 setupListOperation() 的 ProcessCrudController 中添加您的子句:
$this->crud->addClause('has','order');
假設流程模型中指向流程的關系名稱是“order”
- 1 回答
- 0 關注
- 132 瀏覽
添加回答
舉報
0/150
提交
取消