Skip to content

Instantly share code, notes, and snippets.

@jsdecena
Created March 14, 2018 01:42
Show Gist options
  • Save jsdecena/d2ac32da50a769fb0f47fd230d7a33a8 to your computer and use it in GitHub Desktop.
Save jsdecena/d2ac32da50a769fb0f47fd230d7a33a8 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers\Api;
use App\Articles\Repositories\Interfaces\ArticleRepositoryInterface;
use App\Articles\Requests\CreateArticleRequest;
use App\Http\Controllers\Controller;
class ArticlesApiController extends Controller
{
private $articleRepo;
public function __construct(ArticleRepositoryInterface $articleRepository)
{
$this->articleRepo = $articleRepository;
}
/**
* Store all the data request in the database
*
* @param CreateArticleRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function store(CreateArticleRequest $request)
{
$article = $this->articleRepo->create($request->all());
return response()->json($article, 201);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment