2
私のスキーマは次のとおりです。laravelで関係を使用するにはどうすればいいですか?次のように
channel table:
id int unsigned primary key auto increment,
name varchar(30) not null,
...
category table:
id int unsigned primary key auto increment,
channel_id int unsigned index,
name varchar(30) not null,
...
article table:
id int unsigned primary key auto increment,
category_id int unsigned index,
title varchar(90) not null,
content text not null,
...
をので、すべての記事は、特定のカテゴリに属し、カテゴリには、特定のチャネルに属します。
、私の質問は:
私は(関係が私のコードで準備ができている)カテゴリ名とチャンネル名を持つすべての記事を検索することができますか?
、私を助けることができる人を私は
$articles = App\Article::latest()->with('category')->with('channel')->get();
を試してみましたが、それは動作しませんか?あなたの時間をありがとう。
感謝をあなたのアドバイスのために〜 – Snriud