我正在使用laravel,而且我有兩個稱爲捆綁和研究的表格。我從bundleCrudController的表單中添加了一個下拉字段。但我只想在下拉列表中添加那些由登錄用戶創建的研究,而不是研究表中的所有數據。在laravel揹包中的下拉列表中添加自定義值
這裏是我的代碼中加一滴數據下拉列表 -
$this->crud->addField([
'name' => 'studies',
'label' => 'Studies',
'type' => 'select2_from_array',
'options' => $this->Study->getUnallocatedStudies($entryId),
'allows_null' => false,
'hint' => 'Search for the studies you would like to add to this bundle',
'tab' => 'Info',
'allows_multiple' => true
]);
$this->crud->addColumn([
'label' => 'Studies',
'type' => "select_multiple",
'name' => 'bundle_id',
'entity' => 'studies',
'attribute' => 'name',
'model' => "App\Models\Study",
]);
所以請幫助我解決這個問題,以通過登錄的用戶不是所有記錄創建的下拉列表只添加這些記錄..感謝名單
使用model_function或在resources/views/vendor/backpack/crud /字段中創建一個自定義字段,並在該模型或研究模型(或任何你需要的模型)中添加條件添加一個全局範圍(查看所有這些手冊解決方案) – Indra