1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/app/Http/Controllers/DocumentAPIController.php
Holger Lösken 0fbda85a59 Code Refactoring
- Removed unused uses
- Type hinting for method parameters
- Removed commented code
- Introduced comments for classes and methods
- Short array syntax
2016-07-03 16:19:22 +00:00

71 lines
1.5 KiB
PHP

<?php namespace App\Http\Controllers;
use App\Models\Document;
use App\Ninja\Repositories\DocumentRepository;
use App\Http\Requests\DocumentRequest;
use App\Http\Requests\CreateDocumentRequest;
/**
* Class DocumentAPIController
*/
class DocumentAPIController extends BaseAPIController
{
/**
* @var DocumentRepository
*/
protected $documentRepo;
/**
* @var string
*/
protected $entityType = ENTITY_DOCUMENT;
/**
* DocumentAPIController constructor.
*
* @param DocumentRepository $documentRepo
*/
public function __construct(DocumentRepository $documentRepo)
{
parent::__construct();
$this->documentRepo = $documentRepo;
}
/**
* @return \Illuminate\Http\Response
*/
public function index()
{
$documents = Document::scope();
return $this->listResponse($documents);
}
/**
* @param DocumentRequest $request
*
* @return \Illuminate\Http\Response|\Redirect|\Symfony\Component\HttpFoundation\StreamedResponse
*/
public function show(DocumentRequest $request)
{
$document = $request->entity();
return DocumentController::getDownloadResponse($document);
}
/**
* @param CreateDocumentRequest $request
*
* @return \Illuminate\Http\Response
*/
public function store(CreateDocumentRequest $request)
{
$document = $this->documentRepo->upload($request->all());
return $this->itemResponse($document);
}
}