diff --git a/Database/HasBase.php b/Database/HasBase.php index 80a6ac7d..e1c85d84 100644 --- a/Database/HasBase.php +++ b/Database/HasBase.php @@ -24,9 +24,9 @@ abstract class HasBase protected $data; /** - * @var string + * @var IOrm */ - protected string $model; + protected IOrm $model; /** @var */ protected $primaryId; @@ -38,20 +38,20 @@ abstract class HasBase /** @var Relation $_relation */ protected Relation $_relation; - /** - * HasBase constructor. - * @param $model - * @param $primaryId - * @param $value - * @param Relation $relation - * @throws Exception - */ - public function __construct($model, $primaryId, $value, Relation $relation) + /** + * HasBase constructor. + * @param IOrm $model + * @param $primaryId + * @param $value + * @param Relation $relation + * @throws Exception + */ + public function __construct(IOrm $model, $primaryId, $value, Relation $relation) { if (!class_exists($model)) { throw new Exception('Model must implement ' . ActiveRecord::class); } - if (!in_array(ActiveRecord::class, class_implements($model))) { + if (!in_array(IOrm::class, class_implements($model))) { throw new Exception('Model must implement ' . ActiveRecord::class); } if (is_array($value)) { diff --git a/Database/IOrm.php b/Database/IOrm.php index a5cbbbbd..68342d74 100644 --- a/Database/IOrm.php +++ b/Database/IOrm.php @@ -23,6 +23,20 @@ interface IOrm */ public static function findOne($param, $db = NULL); + + /** + * @return string + */ + public static function className(); + + + /** + * @return ActiveQuery + * return a sql queryBuilder + */ + public static function find(); + + /** * @param $dbName * @return Connection