0
laravel 5.3 を使用してコントローラからビューに記事を渡そうとしています。{{$ selectedArticle}}を使用していますフル出力:Laravel - > with()をブレードに表示できません(未定義のプロパティ)
[{"id":5,"title":"Up up and awayy",
"link":"www.google.be",
"points":0,
"userID":1,
"isDeleted":"FALSE",
"created_at":"2017-01-25 23:53:19",
"updated_at":"2017-01-25 23:53:56"
}]
しかし、私は$selectedArticle->id
を使用してみたときに、私は次のエラーを取得する:
Undefined property: Illuminate\Support\Collection::$id
?あなたはビューに渡している変数が配列であるなど、配列を使用すると、ループすべき値を表示する
public function index($id)
{
$comments = DB::table('comments')->orderBy('id')->where(['artikelID' => $id, 'isDeleted' => 'FALSE'])->get();
$article = DB::table('articles')->orderBy('id')->where(['id'=> $id])->get();
return view('comments.comments')
->with('storedComments', $comments)
->with('artikelid',$id)
->with('selectedArticle', $article);
}