Untitled
unknown
php
3 years ago
1.9 kB
2
Indexable
class ManufacturerController extends Controller { /** * Display a listing of the resource. * * @return AnonymousResourceCollection */ public function index() { //return ManufacturerResource::collection(Manufacturer::all()); $manufacturers = Manufacturer::with(['products']); return ManufacturerResource::collection($manufacturers->paginate()); } /** * Store a newly created resource in storage. * * @param StoreManufacturerRequest $request * @return \Illuminate\Http\Response */ public function store(StoreManufacturerRequest $request) { $manufacturer = Manufacturer::create($request->validated()); return ManufacturerResource::make($manufacturer) ->response() ->setStatusCode(ResponseAlias::HTTP_CREATED); } /** * Display the specified resource. * * @param Manufacturer $manufacturer * @return ManufacturerResource */ public function show(Manufacturer $manufacturer): ManufacturerResource { return ManufacturerResource::make($manufacturer); } /** * Update the specified resource in storage. * * @param Request $request * @param Manufacturer $manufacturer * @return ManufacturerResource */ public function update(Request $request, Manufacturer $manufacturer): ManufacturerResource { $manufacturer->update($request->all()); return ManufacturerResource::make($manufacturer); } /** * Remove the specified resource from storage. * * @param Manufacturer $manufacturer * @return Application|ResponseFactory|Response */ public function destroy(Manufacturer $manufacturer) { $manufacturer->delete(); return response(null, ResponseAlias::HTTP_NO_CONTENT); } }
Editor is loading...