finish Events Category crud
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\EventCategoryRequest;
|
||||
use App\Http\Resources\CustomerCatchmentArea;
|
||||
use App\Http\Resources\EventCategory as EventCategoryResource;
|
||||
use App\Models\EventCategory;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -12,28 +13,20 @@ class EventCategoryController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
return response()->json([
|
||||
'data' => EventCategoryResource::collection(EventCategory::orderBy('name')->get()),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(EventCategoryRequest $request)
|
||||
{
|
||||
@@ -50,45 +43,44 @@ class EventCategoryController extends Controller
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\EventCategory $eventCategory
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \App\Models\EventCategory $category
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(EventCategory $eventCategory)
|
||||
public function show(EventCategory $category)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\EventCategory $eventCategory
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(EventCategory $eventCategory)
|
||||
{
|
||||
//
|
||||
return (new EventCategoryResource($category))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\EventCategory $eventCategory
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \App\Models\EventCategory $category
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Request $request, EventCategory $eventCategory)
|
||||
public function update(EventCategoryRequest $request, EventCategory $category)
|
||||
{
|
||||
//
|
||||
$category->update($request->validated());
|
||||
return (new EventCategoryResource($category))
|
||||
->response()
|
||||
->setStatusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\EventCategory $eventCategory
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \App\Models\EventCategory $category
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function destroy(EventCategory $eventCategory)
|
||||
public function destroy(EventCategory $category)
|
||||
{
|
||||
//
|
||||
if(auth()->user()->role === 2) {
|
||||
$category->delete();
|
||||
return response()->json([], 204);
|
||||
} else {
|
||||
return response()->json([], 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user