where('bearer_token', $request->bearer_token)->firstOrFail(); if ($brand != $service->brand) { throw new \Exception('Invalid brand.'); }; return new BrandResource($brand); } /** * Returns the urls for a given brand. * * @param \Illuminate\Http\Request $request * @param Brand $brand * @return \App\Http\Resources\UrlCollection * * @throws \Exception If the brand isn't the brand associated to the service. */ public function getUrls(\Illuminate\Http\Request $request, Brand $brand) { $service = Service::query()->where('bearer_token', $request->bearer_token)->firstOrFail(); if ($brand != $service->brand) { throw new \Exception('Invalid brand.'); }; return new UrlCollection($brand->urls); } }