akaunting 3.0 (the last dance)
This commit is contained in:
@ -4,48 +4,48 @@ namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Common\Report as Request;
|
||||
use App\Http\Resources\Common\Report as Resource;
|
||||
use App\Jobs\Common\CreateReport;
|
||||
use App\Jobs\Common\DeleteReport;
|
||||
use App\Jobs\Common\UpdateReport;
|
||||
use App\Models\Common\Report;
|
||||
use App\Transformers\Common\Report as Transformer;
|
||||
|
||||
class Reports extends ApiController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$reports = Report::collect();
|
||||
|
||||
return $this->response->paginator($reports, new Transformer());
|
||||
return Resource::collection($reports);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param Report $report
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(Report $report)
|
||||
{
|
||||
return $this->item($report, new Transformer());
|
||||
return new Resource($report);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$report = $this->dispatch(new CreateReport($request));
|
||||
|
||||
return $this->response->created(route('api.reports.show', $report->id), $this->item($report, new Transformer()));
|
||||
return $this->created(route('api.reports.show', $report->id), new Resource($report));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,29 +53,29 @@ class Reports extends ApiController
|
||||
*
|
||||
* @param $report
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Report $report, Request $request)
|
||||
{
|
||||
$report = $this->dispatch(new UpdateReport($report, $request));
|
||||
|
||||
return $this->item($report->fresh(), new Transformer());
|
||||
return new Resource($report->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Report $report
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Report $report)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteReport($report));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user