get(); } public function store($request): array { $width = $request->width; $height = $request->height; VideoResolution::create([ 'width' => $width, 'height' => $height, ]); $resolutions = VideoResolution::get(); return [ 'data' => [ 'message' => 'Video resolution has been saved.', 'resolutions' => $resolutions, ], 'status' => 200, ]; } public function update($request): array { $id = $request->id; $width = $request->width; $height = $request->height; $resolution = VideoResolution::find($id); if ($resolution) { $other_resolution = VideoResolution::where('width', $width)->where('height', $height)->where('id', '<>', $id)->first(); if ($other_resolution) { return [ 'data' => [ 'message' => 'Video resolution already exists.', 'resolution' => $other_resolution, ], 'status' => 409, ]; } $resolution->fill($request->all()); $resolution->update(); $resolutions = VideoResolution::get(); return [ 'data' => [ 'message' => 'Video resolution has been udpated.', 'resolutions' => $resolutions ], 'status' => 200, ]; } return [ 'data' => [ 'message' => 'Video resolution not found.', ], 'status' => 404, ]; } public function destroy($request): array { $resolution = VideoResolution::find($request->id); if ($resolution) { $resolution->delete(); $resolutions = VideoResolution::get(); return [ 'data' => [ 'message' => 'Video resolution has been deleted.', 'resolutions' => $resolutions, ], 'status' => 200, ]; } return [ 'data' => [ 'message' => 'Vide resolution not found.', ], 'status' => 404, ]; } }