まず、両方のテーブルの移行を作成する場合、外部キー (FK) を含むテーブルには次のようなフィールドが必要です。
public function up(){
$table->increments('id');
$table->integer('customerID')->unsigned();
}
その後、次のコマンドをコンソールに呼び出す必要があります
php artisan migrate
次は次のコマンドです。
php arisan backpack:crud customers
php arisan backpack:crud transactions
その後、他のテーブルから値を返すモデルで関数を定義する必要があります。顧客モデルには次の機能が必要です
public function transactions(){
return $this->hasMany('Transaction');
}
トランザクション モデルには次の関数が必要です
public function customer() {
return $this->belongsTo('Customer');
}
次に、顧客コントローラーに CRUD フィールドを追加して、選択ボックスにトランザクションを表示する必要があります。
$this->crud->addField([
'label' => 'Transactions', // Label for HTML form field
'type' => 'select2', // HTML element which displaying transactions
'name' => 'customerID', // Table column which is FK for Customer table
'entity'=> 'customer', // Function (method) in Customer model which return transactions
'attribute' => 'ID', // Column which user see in select box
'model' => 'Transaction' // Model which contain FK
]);
お役に立てれば :)