jeudi 4 octobre 2018

How to return collection data to view

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);
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire