私のモデルには次のような状況があります。
-a "users" table, with "id" as primary key
-a "stores" table with "id" as primary key, and "users_id" as foreign key
-a "promos" table with "id" as primary key, and "stores_id" as foreign key
つまり、各プロモーションは 1 つのストアのみに属し、各ストアは 1 人のユーザーのみに属し、関係はモデル ファイルに設定されます。
ログインしたユーザーが自分のプロモーションのみを表示できるようにするアクション/ビューを作成したいのですが、方法がわかりません。
「User.id」はプロモーション テーブルの一部ではないため、次のコードではエラー メッセージが表示されますが、このユーザーが所有するストアのみにプロモーション リストを制限するパラメータを作成する方法がわかりません。
$allPromos = $this->Promo->find('all', array('conditions' => array('Store.id' => $storeId, 'Store.enabled' => 1, 'User.id' => $this->Session->read('id'))));
任意のヒント?
ありがとう!