Skip to content

Commit a437574

Browse files
authored
Update HasOne.php
1 parent 51b3438 commit a437574

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/Database/Barry/Relations/HasOne.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,34 @@
77
use Bow\Cache\Cache;
88
use Bow\Database\Barry\Model;
99
use Bow\Database\Barry\Relation;
10-
use Bow\Database\Exception\QueryBuilderException;
1110

1211
class HasOne extends Relation
1312
{
1413
/**
1514
* Create a new belongs to relationship instance.
1615
*
17-
* @param Model $related
18-
* @param Model $parent
19-
* @param string $foreign_key
20-
* @param string $local_key
16+
* @param Model $related
17+
* @param Model $parent
18+
* @param string $foreign_key
19+
* @param string $local_key
2120
*/
2221
public function __construct(Model $related, Model $parent, string $foreign_key, string $local_key)
2322
{
24-
parent::__construct($related, $parent);
25-
2623
$this->local_key = $local_key;
2724
$this->foreign_key = $foreign_key;
25+
26+
parent::__construct($related, $parent);
2827
}
2928

3029
/**
3130
* Get the results of the relationship.
3231
*
33-
* @return Model|null
32+
* @return Model
3433
*/
35-
public function getResults(): mixed
34+
public function getResults(): ?Model
3635
{
3736
$key = $this->query->getTable() . ":hasone:" . $this->related->getTable() . ":" . $this->foreign_key;
38-
37+
3938
$cache = Cache::store('file')->get($key);
4039

4140
if (!is_null($cache)) {
@@ -57,7 +56,6 @@ public function getResults(): mixed
5756
* Set the base constraints on the relation query.
5857
*
5958
* @return void
60-
* @throws QueryBuilderException
6159
*/
6260
public function addConstraints(): void
6361
{

0 commit comments

Comments
 (0)