我慢してください、私はまだ学んでいます。
私は4つのモデルを持っています:
class Model_Users extends Model_Table {
public $table="users";
function init(){
parent::init();
$this->addField('name')->mandatory('Enter Name');
$this->addField('email')->mandatory('Enter E-Mail');
$this->addField('phone')->mandatory('Enter Phone');
$this->addField('password')->type('password')->mandatory('Enter Password');
$this->addField('is_superadmin')->type('boolean');
$this->addField('is_employee')->type('boolean');
$this->addField('is_manager')->type('boolean');
$this->hasMany('companies');
}
}
class Model_areas extends Model_Table {
public $entity_code='areas';
function init(){
parent::init();
$this->addField('name');
$this->addField('description')->type('text');
//$this->addField('companies_id')->refModel('Model_companies');
$this->hasOne('companies','companies_id','name')->mandatory(true);
$this->hasMany('sites');
}
}
class Model_areas extends Model_Table {
public $entity_code='areas';
function init(){
parent::init();
$this->addField('name');
$this->addField('description')->type('text');
//$this->addField('companies_id')->refModel('Model_companies');
$this->hasOne('companies','companies_id','name')->mandatory(true);
$this->hasMany('sites');
}
}
class Model_sites extends Model_Table {
public $entity_code='sites';
function init(){
parent::init();
$this->addField('name');
$this->addField('description')->type('text');
$this->addField('qrcode');
//$this->addField('Company Name','areas_id')->refModel('Model_companies','name');
$this->hasOne('areas','areas_id','name');
}
}
私は「サイト」モデルを単純なクラッドに持っています。関連する hasOne レコードを「area」から正常にプルしています。2 つの質問があります。
1) 結合領域列の列名を変更するにはどうすればよいですか? 「エリア」とだけ書かれていますが、「エリア名」にしたいのですが
grid->addColumn
2) そして、より複雑なもの:の領域にリンクされた会社名を取得する、結果の CRUD (またはグリッドである必要があるでしょうか?) に対して、どのように実行できareas_id
ますか? そのすべては、1 対多の関係です。会社には複数の領域があります。Areas には複数のサイトがあります。サイトの CRUD ビューに会社名を追加したい。
コメント行で、これを達成するための私の小さな試みのいくつかを見ることができます。それから、私は何か大きなものを失っていることに気づきました。このモデルをシンプルに保ち、単純に関係をたどることができるはずです..
ご協力ありがとうございました。
これらのチュートリアル ビデオに戻ります。
編集:わかりました列名をOKします。->caption('Blah')
. まだトラバーサルを理解できません:(