Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
9dc71e4d77 | |||
65bec43b45 | |||
c6806a1c62 | |||
5f3f6b72e5 |
@ -37,7 +37,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
|||||||
}
|
}
|
||||||
return $definitions;
|
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, [
|
$relation_definitions = $this->checkDefinitions($relation_definitions, [
|
||||||
Model::SELF_KEY,
|
Model::SELF_KEY,
|
||||||
Model::CHILD_KEY
|
Model::CHILD_KEY
|
||||||
@ -54,7 +54,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
|||||||
])
|
])
|
||||||
->many();
|
->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, [
|
$relation_definitions = $this->checkDefinitions($relation_definitions, [
|
||||||
Model::SELF_KEY,
|
Model::SELF_KEY,
|
||||||
Model::PARENT_KEY
|
Model::PARENT_KEY
|
||||||
@ -72,7 +72,7 @@ abstract class Model extends BaseModel implements ModelInterface {
|
|||||||
])
|
])
|
||||||
->one();
|
->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, [
|
$relation_definitions = $this->checkDefinitions($relation_definitions, [
|
||||||
Model::SELF_KEY,
|
Model::SELF_KEY,
|
||||||
Model::SIBLING_KEY,
|
Model::SIBLING_KEY,
|
||||||
|
@ -29,7 +29,7 @@ class Model {
|
|||||||
$model = $model->where([[$f, $v]]);
|
$model = $model->where([[$f, $v]]);
|
||||||
}
|
}
|
||||||
$model = $model->one();
|
$model = $model->one();
|
||||||
if ($model !== false) {
|
if ($model !== null) {
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ class Model {
|
|||||||
public function one($id = null): ?ModelInterface {
|
public function one($id = null): ?ModelInterface {
|
||||||
$result = $this->build()->findOne($id);
|
$result = $this->build()->findOne($id);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
$result->setFactory($this);
|
$result->setFactory($this);
|
||||||
return $result;
|
return $result;
|
||||||
@ -353,7 +353,7 @@ class Model {
|
|||||||
public function many(): ?array {
|
public function many(): ?array {
|
||||||
$results = $this->build()->findMany();
|
$results = $this->build()->findMany();
|
||||||
if (!$results) {
|
if (!$results) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
foreach ($results as &$r) {
|
foreach ($results as &$r) {
|
||||||
$r->setFactory($this);
|
$r->setFactory($this);
|
||||||
@ -363,7 +363,7 @@ class Model {
|
|||||||
public function array(): ?array {
|
public function array(): ?array {
|
||||||
$results = $this->build()->findArray();
|
$results = $this->build()->findArray();
|
||||||
if (!$results) {
|
if (!$results) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user