diff --git a/traits/FindModelTrait.php b/traits/FindModelTrait.php index a8f48c2..d835278 100644 --- a/traits/FindModelTrait.php +++ b/traits/FindModelTrait.php @@ -12,25 +12,22 @@ */ trait FindModelTrait { - /** - * @var string message for the NotFoundHttpException - */ - protected $notFoundMessage = 'The requested page does not exist.'; - /** * Finds model * * @param $modelClass ActiveRecord * @param mixed $condition primary key value or a set of column values + * @param string $notFoundMessage * @return ActiveRecord + * * @throws NotFoundHttpException */ - protected function findModel($modelClass, $condition) + protected function findModel($modelClass, $condition, $notFoundMessage = 'The requested page does not exist.') { if (($model = $modelClass::findOne($condition)) !== null) { return $model; } else { - throw new NotFoundHttpException($this->notFoundMessage); + throw new NotFoundHttpException($notFoundMessage); } } -} \ No newline at end of file +}