maybeUpdateFromExternal(); if (!$title) { abort(404); } } $response = ['title' => $title->loadCount('seasons')]; foreach (explode(',', Arr::get($params, 'load', '')) as $relation) { $methodName = sprintf('load%s', Str::camel($relation)); if (method_exists($this, $methodName)) { $response = $this->$methodName($title, $params, $response); } elseif (method_exists($title, $relation)) { $title->load($relation); } } foreach ( explode(',', Arr::get($params, 'loadCount', '')) as $relation ) { if (method_exists($title, $relation)) { $title->loadCount($relation); } } return $response; } }