1 | <?php |
||
11 | abstract class HasOneOrMany extends Relation |
||
12 | { |
||
13 | /** |
||
14 | * The foreign key of the parent model. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $foreignKey; |
||
19 | |||
20 | /** |
||
21 | * The local key of the parent model. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $localKey; |
||
26 | |||
27 | /** |
||
28 | * Create a new has one or many relationship instance. |
||
29 | * |
||
30 | * @param \Magister\Services\Database\Elegant\Builder $query |
||
31 | * @param \Magister\Services\Database\Elegant\Model $parent |
||
32 | * @param string $foreignKey |
||
33 | * @param string $localKey |
||
34 | */ |
||
35 | public function __construct(Builder $query, Model $parent, $foreignKey, $localKey) |
||
42 | |||
43 | /** |
||
44 | * Set the base constraints on the relation query. |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | public function addConstraints() |
||
54 | |||
55 | /** |
||
56 | * Get the foreign key for the relationship. |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | public function getForeignKey() |
||
64 | |||
65 | /** |
||
66 | * Get the key value of the parent's local key. |
||
67 | * |
||
68 | * @return mixed |
||
69 | */ |
||
70 | public function getParentKey() |
||
74 | } |
||
75 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: