Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@developerdino
Created September 7, 2017 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save developerdino/2af5f2263465980004ed585f8954c8c6 to your computer and use it in GitHub Desktop.
Save developerdino/2af5f2263465980004ed585f8954c8c6 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use App\Article;
use App\Http\Resources\ArticleResource;
use App\Http\Resources\ArticlesResource;
use Illuminate\Http\Request;
class ArticleController extends Controller
{
/**
* Display a listing of the resource.
*
* @return ArticlesResource
*/
public function index()
{
return new ArticlesResource(Article::with(['author', 'comments.author'])->paginate());
}
/**
* Display the specified resource.
*
* @param \App\Article $article
*
* @return ArticleResource
*/
public function show(Article $article)
{
ArticleResource::withoutWrapping();
return new ArticleResource($article);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment