relations widgets for backpack
3.3.1

composer require izica/relations-widgets-for-backpack


関係パネル
name - リレーションの名前label - パネルラベルbackpack_crud - バックパックのクルード URL、buttons (オプション) - すべてのアクション ボタンを非表示にするにはfalse設定します。button_show (オプション) - 非表示にするにはfalse設定します。button_edit (オプション) - 非表示にするにはfalse設定します。visible (オプション) - パネルを非表示または表示するためのクロージャfields (オプション) - フィールド配列。デフォルトではモデル内のfillable列から列を取得します。name - 名前label - フィールド用closure - 名前フィールドの代わりにクロージャを使用します。visible (オプション) - パネルを非表示または表示するためのクロージャ関係テーブル
name - (必須) リレーションの名前label - パネルラベルrelation_attribute - (オプション) button_create の URL パラメータ名を渡すために使用されます。search - (オプション) closure 、検索入力を有効にしますper_page - (オプション) ページネーションを有効にします。デフォルトではnullbackpack_crud - バックパックのクルード URL、buttons (オプション) - すべてのアクション ボタンを非表示にするにはfalse設定します。button_create (オプション) - 非表示にするにはfalse設定します。button_show (オプション) - 非表示にするにはfalse設定します。button_edit (オプション) - 非表示にするにはfalse設定します。button_delete (オプション) - 非表示にするにはfalse設定します。visible (オプション) - パネルを非表示または表示するためのclosurecolumns (オプション) - columns array 、デフォルトではモデル内のfillable列から列を取得します。name - 名前label - フィールド用closure - 値を渡すために名前フィールドの代わりにclosureを使用します。belongsTo 、 hasOne
use Backpack CRUD app Library Widget ;
protected function setupShowOperation ()
{
Widget:: add ([
' type ' => ' relation_panel ' ,
' name ' => ' account_contact ' ,
' label ' => ' Account contact info ' ,
' backpack_crud ' => ' accountcontact ' ,
' visible ' => function ( $ entry ){
return $ entry -> is_public_person ;
},
' buttons ' => false ,
' fields ' => [
[
' label ' => ' Birthdate ' ,
' closure ' => function ( $ entry ){
return date ( ' d.M.Y ' , $ entry -> birthdate );
}
],
[
' label ' => ' Contact phone ' ,
' name ' => ' contact_phone ' ,
],
[
' label ' => ' Contact email ' ,
' name ' => ' contact_email ' ,
],
[
' label ' => ' Address ' ,
' name ' => ' address.name ' ,
' visible ' => function ( $ entry ){
return !! $ entry -> address ;
}
],
],
])-> to ( ' after_content ' );
}hasMany
protected function setupShowOperation ()
{
Widget:: add ([
' type ' => ' relation_table ' ,
' name ' => ' order_cargos ' ,
' label ' => ' Order cargo list ' ,
' backpack_crud ' => ' ordercargo ' ,
' visible ' => function ( $ entry ){
return $ entry -> order_cargos -> count () > 0 ;
},
' search ' => function ( $ query , $ search ) {
return $ query -> where ( ' name ' , ' like ' , " % { $ search } % " );
},
' relation_attribute ' => ' order_id ' ,
' button_create ' => true ,
' button_delete ' => false ,
' columns ' => [
[
' label ' => ' Type ' ,
' name ' => ' order_cargo_type.name ' ,
],
[
' label ' => ' Weight ' ,
' name ' => ' weight ' ,
],
[
' label ' => ' Value, $ ' ,
' closure ' => function ( $ entry ){
return "{ $ entry -> value } $ " ;
}
],
],
])-> to ( ' after_content ' );
}以下を設定する必要があります:
button_create => truerelation_attribute => attribute_name次に、リレーション/選択フィールドのdefault値を追加する必要があります。
CRUD :: addField ([
' type ' => " relationship " ,
' name ' => ' order ' ,
' default ' => $ _GET [ ' order_id ' ] ?? null
]);