akaunting 3.0 (the last dance)
This commit is contained in:
@ -4,13 +4,13 @@ namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Common\Company as Request;
|
||||
use App\Http\Resources\Common\Company as Resource;
|
||||
use App\Jobs\Common\CreateCompany;
|
||||
use App\Jobs\Common\DeleteCompany;
|
||||
use App\Jobs\Common\UpdateCompany;
|
||||
use App\Models\Common\Company;
|
||||
use App\Transformers\Common\Company as Transformer;
|
||||
use App\Traits\Users;
|
||||
use Dingo\Api\Http\Response;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class Companies extends ApiController
|
||||
{
|
||||
@ -19,20 +19,20 @@ class Companies extends ApiController
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$companies = user()->companies()->collect();
|
||||
|
||||
return $this->response->paginator($companies, new Transformer());
|
||||
return Resource::collection($companies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param Company $company
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(Company $company)
|
||||
{
|
||||
@ -40,9 +40,9 @@ class Companies extends ApiController
|
||||
// Check if user can access company
|
||||
$this->canAccess($company);
|
||||
|
||||
return $this->item($company, new Transformer());
|
||||
return new Resource($company);
|
||||
} catch (\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,13 +50,13 @@ class Companies extends ApiController
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$company = $this->dispatch(new CreateCompany($request));
|
||||
|
||||
return $this->response->created(route('api.companies.show', $company->id), $this->item($company, new Transformer()));
|
||||
return $this->created(route('api.companies.show', $company->id), new Resource($company));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,16 +64,16 @@ class Companies extends ApiController
|
||||
*
|
||||
* @param $company
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Company $company, Request $request)
|
||||
{
|
||||
try {
|
||||
$company = $this->dispatch(new UpdateCompany($company, $request));
|
||||
|
||||
return $this->item($company->fresh(), new Transformer());
|
||||
return new Resource($company->fresh());
|
||||
} catch (\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,16 +81,16 @@ class Companies extends ApiController
|
||||
* Enable the specified resource in storage.
|
||||
*
|
||||
* @param Company $company
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function enable(Company $company)
|
||||
{
|
||||
try {
|
||||
$company = $this->dispatch(new UpdateCompany($company, request()->merge(['enabled' => 1])));
|
||||
|
||||
return $this->item($company->fresh(), new Transformer());
|
||||
return new Resource($company->fresh());
|
||||
} catch (\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,16 +98,16 @@ class Companies extends ApiController
|
||||
* Disable the specified resource in storage.
|
||||
*
|
||||
* @param Company $company
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function disable(Company $company)
|
||||
{
|
||||
try {
|
||||
$company = $this->dispatch(new UpdateCompany($company, request()->merge(['enabled' => 0])));
|
||||
|
||||
return $this->item($company->fresh(), new Transformer());
|
||||
return new Resource($company->fresh());
|
||||
} catch (\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,16 +115,16 @@ class Companies extends ApiController
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Company $company
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Company $company)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteCompany($company));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch (\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,16 +133,16 @@ class Companies extends ApiController
|
||||
*
|
||||
* @param Company $company
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function canAccess(Company $company)
|
||||
{
|
||||
if (!empty($company) && $this->isUserCompany($company->id)) {
|
||||
if (! empty($company) && $this->isUserCompany($company->id)) {
|
||||
return new Response('');
|
||||
}
|
||||
|
||||
$message = trans('companies.error.not_user_company');
|
||||
|
||||
$this->response->errorUnauthorized($message);
|
||||
$this->errorUnauthorized($message);
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Common\Contact as Request;
|
||||
use App\Http\Resources\Common\Contact as Resource;
|
||||
use App\Jobs\Common\CreateContact;
|
||||
use App\Jobs\Common\DeleteContact;
|
||||
use App\Jobs\Common\UpdateContact;
|
||||
use App\Models\Common\Contact;
|
||||
use App\Traits\Uploads;
|
||||
use App\Transformers\Common\Contact as Transformer;
|
||||
|
||||
class Contacts extends ApiController
|
||||
{
|
||||
@ -18,20 +18,20 @@ class Contacts extends ApiController
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$contacts = Contact::collect();
|
||||
|
||||
return $this->response->paginator($contacts, new Transformer());
|
||||
return Resource::collection($contacts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int|string $id
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
@ -42,20 +42,20 @@ class Contacts extends ApiController
|
||||
$contact = Contact::where('email', $id)->first();
|
||||
}
|
||||
|
||||
return $this->item($contact, new Transformer());
|
||||
return new Resource($contact);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$contact = $this->dispatch(new CreateContact($request));
|
||||
|
||||
return $this->response->created(route('api.contacts.show', $contact->id), $this->item($contact, new Transformer()));
|
||||
return $this->created(route('api.contacts.show', $contact->id), new Resource($contact));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,42 +63,42 @@ class Contacts extends ApiController
|
||||
*
|
||||
* @param $contact
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Contact $contact, Request $request)
|
||||
{
|
||||
$contact = $this->dispatch(new UpdateContact($contact, $request));
|
||||
|
||||
return $this->item($contact->fresh(), new Transformer());
|
||||
return new Resource($contact->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the specified resource in storage.
|
||||
*
|
||||
* @param Contact $contact
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function enable(Contact $contact)
|
||||
{
|
||||
$contact = $this->dispatch(new UpdateContact($contact, request()->merge(['enabled' => 1])));
|
||||
|
||||
return $this->item($contact->fresh(), new Transformer());
|
||||
return new Resource($contact->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the specified resource in storage.
|
||||
*
|
||||
* @param Contact $contact
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function disable(Contact $contact)
|
||||
{
|
||||
try {
|
||||
$contact = $this->dispatch(new UpdateContact($contact, request()->merge(['enabled' => 0])));
|
||||
|
||||
return $this->item($contact->fresh(), new Transformer());
|
||||
return new Resource($contact->fresh());
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,16 +106,16 @@ class Contacts extends ApiController
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Contact $contact
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Contact $contact)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteContact($contact));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,13 @@ namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Common\Dashboard as Request;
|
||||
use App\Http\Resources\Common\Dashboard as Resource;
|
||||
use App\Jobs\Common\CreateDashboard;
|
||||
use App\Jobs\Common\DeleteDashboard;
|
||||
use App\Jobs\Common\UpdateDashboard;
|
||||
use App\Models\Common\Dashboard;
|
||||
use App\Transformers\Common\Dashboard as Transformer;
|
||||
use App\Traits\Users;
|
||||
use Dingo\Api\Http\Response;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class Dashboards extends ApiController
|
||||
{
|
||||
@ -19,20 +19,20 @@ class Dashboards extends ApiController
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$dashboards = user()->dashboards()->with('widgets')->collect();
|
||||
|
||||
return $this->response->paginator($dashboards, new Transformer());
|
||||
return Resource::collection($dashboards);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int|string $id
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
@ -42,9 +42,9 @@ class Dashboards extends ApiController
|
||||
// Check if user can access dashboard
|
||||
$this->canAccess($dashboard);
|
||||
|
||||
return $this->item($dashboard, new Transformer());
|
||||
return new Resource($dashboard);
|
||||
} catch (\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,13 +52,13 @@ class Dashboards extends ApiController
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$dashboard = $this->dispatch(new CreateDashboard($request));
|
||||
|
||||
return $this->response->created(route('api.dashboards.show', $dashboard->id), $this->item($dashboard, new Transformer()));
|
||||
return $this->created(route('api.dashboards.show', $dashboard->id), new Resource($dashboard));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,16 +66,16 @@ class Dashboards extends ApiController
|
||||
*
|
||||
* @param $dashboard
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Dashboard $dashboard, Request $request)
|
||||
{
|
||||
try {
|
||||
$dashboard = $this->dispatch(new UpdateDashboard($dashboard, $request));
|
||||
|
||||
return $this->item($dashboard->fresh(), new Transformer());
|
||||
return new Resource($dashboard->fresh());
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,16 +83,16 @@ class Dashboards extends ApiController
|
||||
* Enable the specified resource in storage.
|
||||
*
|
||||
* @param Dashboard $dashboard
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function enable(Dashboard $dashboard)
|
||||
{
|
||||
try {
|
||||
$dashboard = $this->dispatch(new UpdateDashboard($dashboard, request()->merge(['enabled' => 1])));
|
||||
|
||||
return $this->item($dashboard->fresh(), new Transformer());
|
||||
return new Resource($dashboard->fresh());
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,16 +100,16 @@ class Dashboards extends ApiController
|
||||
* Disable the specified resource in storage.
|
||||
*
|
||||
* @param Dashboard $dashboard
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function disable(Dashboard $dashboard)
|
||||
{
|
||||
try {
|
||||
$dashboard = $this->dispatch(new UpdateDashboard($dashboard, request()->merge(['enabled' => 0])));
|
||||
|
||||
return $this->item($dashboard->fresh(), new Transformer());
|
||||
return new Resource($dashboard->fresh());
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,16 +117,16 @@ class Dashboards extends ApiController
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Dashboard $dashboard
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Dashboard $dashboard)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteDashboard($dashboard));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ class Dashboards extends ApiController
|
||||
*
|
||||
* @param Dashboard $dashboard
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function canAccess($dashboard)
|
||||
{
|
||||
@ -145,6 +145,6 @@ class Dashboards extends ApiController
|
||||
|
||||
$message = trans('dashboards.error.not_user_dashboard');
|
||||
|
||||
$this->response->errorUnauthorized($message);
|
||||
$this->errorUnauthorized($message);
|
||||
}
|
||||
}
|
||||
|
@ -4,50 +4,50 @@ namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Http\Requests\Common\Item as Request;
|
||||
use App\Http\Resources\Common\Item as Resource;
|
||||
use App\Jobs\Common\CreateItem;
|
||||
use App\Jobs\Common\DeleteItem;
|
||||
use App\Jobs\Common\UpdateItem;
|
||||
use App\Models\Common\Item;
|
||||
use App\Transformers\Common\Item as Transformer;
|
||||
|
||||
class Items extends ApiController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$items = Item::with('category', 'taxes')->collect();
|
||||
|
||||
return $this->response->paginator($items, new Transformer());
|
||||
return Resource::collection($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int|string $id
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$item = Item::with('category', 'taxes')->find($id);
|
||||
|
||||
return $this->item($item, new Transformer());
|
||||
return new Resource($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$item = $this->dispatch(new CreateItem($request));
|
||||
|
||||
return $this->response->created(route('api.items.show', $item->id), $this->item($item, new Transformer()));
|
||||
return $this->created(route('api.items.show', $item->id), new Resource($item));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,55 +55,55 @@ class Items extends ApiController
|
||||
*
|
||||
* @param $item
|
||||
* @param $request
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Item $item, Request $request)
|
||||
{
|
||||
$item = $this->dispatch(new UpdateItem($item, $request));
|
||||
|
||||
return $this->item($item->fresh(), new Transformer());
|
||||
return new Resource($item->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the specified resource in storage.
|
||||
*
|
||||
* @param Item $item
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function enable(Item $item)
|
||||
{
|
||||
$item = $this->dispatch(new UpdateItem($item, request()->merge(['enabled' => 1])));
|
||||
|
||||
return $this->item($item->fresh(), new Transformer());
|
||||
return new Resource($item->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the specified resource in storage.
|
||||
*
|
||||
* @param Item $item
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function disable(Item $item)
|
||||
{
|
||||
$item = $this->dispatch(new UpdateItem($item, request()->merge(['enabled' => 0])));
|
||||
|
||||
return $this->item($item->fresh(), new Transformer());
|
||||
return new Resource($item->fresh());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Item $item
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Item $item)
|
||||
{
|
||||
try {
|
||||
$this->dispatch(new DeleteItem($item));
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
} catch(\Exception $e) {
|
||||
$this->response->errorUnauthorized($e->getMessage());
|
||||
$this->errorUnauthorized($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,10 @@
|
||||
namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use Date;
|
||||
use Dingo\Api\Routing\Helpers;
|
||||
use App\Utilities\Date;
|
||||
|
||||
class Ping extends ApiController
|
||||
{
|
||||
use Helpers;
|
||||
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
@ -23,9 +20,9 @@ class Ping extends ApiController
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
public function pong()
|
||||
{
|
||||
return $this->response->array([
|
||||
return response()->json([
|
||||
'status' => 'ok',
|
||||
'timestamp' => Date::now(),
|
||||
]);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers\Api\Common;
|
||||
|
||||
use App\Abstracts\Http\ApiController;
|
||||
use App\Models\Module\Module;
|
||||
use Dingo\Api\Http\Response;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Str;
|
||||
@ -16,7 +15,7 @@ class Translations extends ApiController
|
||||
*
|
||||
* @param string $locale
|
||||
* @param string $file
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function file($locale, $file)
|
||||
{
|
||||
@ -34,7 +33,7 @@ class Translations extends ApiController
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param string $locale
|
||||
* @return \Dingo\Api\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function all($locale)
|
||||
{
|
||||
|
Reference in New Issue
Block a user