From 4d052efba666d201cefeeb51a266047b1709fe4e Mon Sep 17 00:00:00 2001 From: kj Date: Sat, 25 Mar 2023 18:28:21 -0400 Subject: [PATCH] Change return type from mixed to ?Model on getFirts and getById methods. --- src/Libs/Model.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Libs/Model.php b/src/Libs/Model.php index 46b90f6..ef9c78e 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -702,9 +702,10 @@ class Model { * Si no encuentra una instancia, devuelve nulo. * * @param mixed $id - * @return mixed + * + * @return Model|null */ - public static function getById($id) { + public static function getById($id): ?Model { return static::where(static::$primaryKey, $id)->getFirst(); } @@ -774,10 +775,10 @@ class Model { * @param bool $resetQuery * (opcional) Indica si el query debe reiniciarse o no (por defecto es true). * - * @return mixed + * @return Model|null * Puede retornar un objeto Model o null. */ - public static function getFirst(bool $resetQuery = true) { // Devuelve null si no encuentra nada. + public static function getFirst(bool $resetQuery = true): ?Model { // Devuelve null si no encuentra nada. static::limit(1); $instances = static::get($resetQuery); return empty($instances) ? null : $instances[0];