I am newbie in laravel. I want to know how can I pass the data result from the resource collection to view. I saw in tutorial if I have not uses resource then I can simply return like this to view.
return view('articles.index')->with('posts', $posts);
I was practicing using resource collection, I am not sure how to return to view.
public function index()
{
$articles = Article::all();
return ArticleResource::collection($articles);
}
I have tried using following which returns data to the view but I am not being able to show that data.
return view('articles.index')->with('articles', ArticleResource::collection($articles));
'article' => (new ArticleResource($article))->resolve(),
Consider that this way it become an array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With