Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/SkusController.php
<?php | <?php | ||||
namespace App\Http\Controllers\API\V4; | namespace App\Http\Controllers\API\V4; | ||||
use App\Http\Controllers\Controller; | use App\Http\Controllers\ResourceController; | ||||
use App\Sku; | use App\Sku; | ||||
use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||
class SkusController extends Controller | class SkusController extends ResourceController | ||||
{ | { | ||||
/** | /** | ||||
* Show the form for creating a new sku. | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function create() | |||||
{ | |||||
// TODO | |||||
return $this->errorResponse(404); | |||||
} | |||||
/** | |||||
* Remove the specified sku from storage. | |||||
* | |||||
* @param int $id SKU identifier | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function destroy($id) | |||||
{ | |||||
// TODO | |||||
return $this->errorResponse(404); | |||||
} | |||||
/** | |||||
* Get a list of SKUs available to the domain. | * Get a list of SKUs available to the domain. | ||||
* | * | ||||
* @param int $id Domain identifier | * @param int $id Domain identifier | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function domainSkus($id) | public function domainSkus($id) | ||||
{ | { | ||||
$domain = \App\Domain::find($id); | $domain = \App\Domain::find($id); | ||||
if (!$this->checkTenant($domain)) { | if (!$this->checkTenant($domain)) { | ||||
return $this->errorResponse(404); | return $this->errorResponse(404); | ||||
} | } | ||||
if (!$this->guard()->user()->canRead($domain)) { | if (!$this->guard()->user()->canRead($domain)) { | ||||
return $this->errorResponse(403); | return $this->errorResponse(403); | ||||
} | } | ||||
return $this->objectSkus($domain); | return $this->objectSkus($domain); | ||||
} | } | ||||
/** | /** | ||||
* Show the form for editing the specified sku. | |||||
* | |||||
* @param int $id SKU identifier | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function edit($id) | |||||
{ | |||||
// TODO | |||||
return $this->errorResponse(404); | |||||
} | |||||
/** | |||||
* Get a list of active SKUs. | * Get a list of active SKUs. | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function index() | public function index() | ||||
{ | { | ||||
// Note: Order by title for consistent ordering in tests | // Note: Order by title for consistent ordering in tests | ||||
$skus = Sku::withSubjectTenantContext()->where('active', true)->orderBy('title')->get(); | $skus = Sku::withSubjectTenantContext()->where('active', true)->orderBy('title')->get(); | ||||
Show All 9 Lines | public function index() | ||||
usort($response, function ($a, $b) { | usort($response, function ($a, $b) { | ||||
return ($b['prio'] <=> $a['prio']); | return ($b['prio'] <=> $a['prio']); | ||||
}); | }); | ||||
return response()->json($response); | return response()->json($response); | ||||
} | } | ||||
/** | /** | ||||
* Store a newly created sku in storage. | |||||
* | |||||
* @param \Illuminate\Http\Request $request | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function store(Request $request) | |||||
{ | |||||
// TODO | |||||
return $this->errorResponse(404); | |||||
} | |||||
/** | |||||
* Display the specified sku. | |||||
* | |||||
* @param int $id SKU identifier | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function show($id) | |||||
{ | |||||
// TODO | |||||
return $this->errorResponse(404); | |||||
} | |||||
/** | |||||
* Update the specified sku in storage. | |||||
* | |||||
* @param \Illuminate\Http\Request $request Request object | |||||
* @param int $id SKU identifier | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function update(Request $request, $id) | |||||
{ | |||||
// TODO | |||||
return $this->errorResponse(404); | |||||
} | |||||
/** | |||||
* Get a list of SKUs available to the user. | * Get a list of SKUs available to the user. | ||||
* | * | ||||
* @param int $id User identifier | * @param int $id User identifier | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function userSkus($id) | public function userSkus($id) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |