Compare commits
6 Commits
0.1.13
...
43f545516d
Author | SHA1 | Date | |
---|---|---|---|
43f545516d | |||
4d64143dbc | |||
b757ed19b2 | |||
1dc21d8fb7 | |||
9dc71e4d77 | |||
65bec43b45 |
@ -6,9 +6,9 @@ use ProVM\Common\Factory\Model as ModelFactory;
|
||||
interface Model {
|
||||
public function getTable(): string;
|
||||
public function setFactory(ModelFactory $factory): Model;
|
||||
public function parentOf(string $child_model_class, array $relation_definitions): array;
|
||||
public function childOf(string $parent_model_class, array $relation_definitions): Model;
|
||||
public function siblingOf(string $sibling_model_class, string $connecting_table, array $relation_definitions): array;
|
||||
public function parentOf(string $child_model_class, array $relation_definitions): ?array;
|
||||
public function childOf(string $parent_model_class, array $relation_definitions): ?Model;
|
||||
public function siblingOf(string $sibling_model_class, string $connecting_table, array $relation_definitions): ?array;
|
||||
|
||||
public function toArray(): array;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
||||
}
|
||||
return $definitions;
|
||||
}
|
||||
public function parentOf(string $child_model_class, array $relation_definitions): array {
|
||||
public function parentOf(string $child_model_class, array $relation_definitions): ?array {
|
||||
$relation_definitions = $this->checkDefinitions($relation_definitions, [
|
||||
Model::SELF_KEY,
|
||||
Model::CHILD_KEY
|
||||
@ -54,7 +54,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
||||
])
|
||||
->many();
|
||||
}
|
||||
public function childOf(string $parent_model_class, array $relation_definitions): ModelInterface {
|
||||
public function childOf(string $parent_model_class, array $relation_definitions): ?ModelInterface {
|
||||
$relation_definitions = $this->checkDefinitions($relation_definitions, [
|
||||
Model::SELF_KEY,
|
||||
Model::PARENT_KEY
|
||||
@ -72,7 +72,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
||||
])
|
||||
->one();
|
||||
}
|
||||
public function siblingOf(string $sibling_model_class, string $connecting_table, array $relation_definitions): array {
|
||||
public function siblingOf(string $sibling_model_class, string $connecting_table, array $relation_definitions): ?array {
|
||||
$relation_definitions = $this->checkDefinitions($relation_definitions, [
|
||||
Model::SELF_KEY,
|
||||
Model::SIBLING_KEY,
|
||||
|
@ -33,7 +33,9 @@ class Model {
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
return BaseModel::factory($model_class)->create($data);
|
||||
$model = BaseModel::factory($model_class)->create($data);
|
||||
$model->setFactory($this);
|
||||
return $model;
|
||||
}
|
||||
protected $class;
|
||||
public function find(string $model_class): Model {
|
||||
|
Reference in New Issue
Block a user