protected function findResource()
{
$resource = null;
if (array_key_exists('singleton', $this->options) && respond_to($this->getParentResource(), $this->getName())) {
$resource = call_user_func([$this->getParentResource(), $this->getName()]);
} else {
$resourceModel = app($this->getResourceBase());
if (array_key_exists('findBy', $this->options)) {
if (respond_to($resourceModel, "findBy" . studly_case($this->options['findBy']))) {
$resource = call_user_func_array([$resourceModel, "findBy" . studly_case($this->options['findBy'])], [$this->getIdParam()]);
} elseif (respond_to($resourceModel, camel_case($this->options['findBy']))) {
$resource = call_user_func_array([$resourceModel, camel_case($this->options['findBy'])], [$this->getIdParam()]);
} else {
$resource = $resourceModel->where($this->getResourcePrimaryKey(), $this->getIdParam())->firstOrFail();
}
} else {
$resource = $resourceModel->where($this->getResourcePrimaryKey(), $this->getIdParam())->firstOrFail();
}
}
if (!is_null($resource)) {
return $resource;
}
throw new \Illuminate\Database\Eloquent\ModelNotFoundException();
}