public function getProfile($id) { /** @var Profile $profile */ $profile = Profile::approved()->with(['logo', 'hero', 'posts'])->find($id); if (is_null($profile)) { return response()->json(['error' => 'Profile not found.'], 404); } else { return response()->json($profile->toDetailedArray()); } }