亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在其他控制器中使用CRUD控制器索引(列表)

如何在其他控制器中使用CRUD控制器索引(列表)

PHP
慕哥9229398 2023-08-19 17:27:19
我想制作僅具有關系的表的列表,例如:桌子:命令過程在 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”


查看完整回答
反對 回復 2023-08-19
  • 1 回答
  • 0 關注
  • 132 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號