2016-05-21 10:44:53 +02:00
|
|
|
<?php namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Document;
|
|
|
|
|
2016-05-30 12:44:49 +02:00
|
|
|
use App\Ninja\Repositories\DocumentRepository;
|
|
|
|
use App\Http\Requests\DocumentRequest;
|
|
|
|
use App\Http\Requests\CreateDocumentRequest;
|
|
|
|
|
2016-05-21 10:44:53 +02:00
|
|
|
class DocumentAPIController extends BaseAPIController
|
|
|
|
{
|
2016-05-30 12:44:49 +02:00
|
|
|
protected $documentRepo;
|
|
|
|
|
|
|
|
protected $entityType = ENTITY_DOCUMENT;
|
2016-05-21 10:44:53 +02:00
|
|
|
|
2016-05-30 12:44:49 +02:00
|
|
|
public function __construct(DocumentRepository $documentRepo)
|
2016-05-21 10:44:53 +02:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
2016-05-30 12:44:49 +02:00
|
|
|
$this->documentRepo = $documentRepo;
|
2016-05-21 10:44:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
2016-06-05 12:00:21 +02:00
|
|
|
$documents = Document::scope()->get();
|
|
|
|
|
2016-06-05 12:13:38 +02:00
|
|
|
return $this->listResponse($documents);
|
2016-06-05 12:00:21 +02:00
|
|
|
|
2016-05-21 10:44:53 +02:00
|
|
|
}
|
|
|
|
|
2016-05-30 12:44:49 +02:00
|
|
|
public function show(DocumentRequest $request)
|
2016-05-21 10:44:53 +02:00
|
|
|
{
|
2016-05-30 12:44:49 +02:00
|
|
|
$document = $request->entity();
|
2016-05-21 10:44:53 +02:00
|
|
|
|
|
|
|
return DocumentController::getDownloadResponse($document);
|
|
|
|
}
|
|
|
|
|
2016-05-30 12:44:49 +02:00
|
|
|
public function store(CreateDocumentRequest $request)
|
2016-05-21 10:44:53 +02:00
|
|
|
{
|
2016-06-01 12:15:31 +02:00
|
|
|
|
2016-06-01 11:39:42 +02:00
|
|
|
$document = $this->documentRepo->upload($request->all());
|
2016-05-30 12:44:49 +02:00
|
|
|
|
|
|
|
return $this->itemResponse($document);
|
2016-05-21 10:44:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function update()
|
|
|
|
{
|
|
|
|
//stub
|
|
|
|
}
|
|
|
|
|
|
|
|
public function destroy($publicId)
|
|
|
|
{
|
|
|
|
//stub
|
|
|
|
}
|
|
|
|
}
|