Total Complexity | 4 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 63.64% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | trait HasRelationships |
||
16 | { |
||
17 | use BelongsTo, |
||
18 | HasOne, |
||
19 | HasMany; |
||
20 | |||
21 | /** |
||
22 | * Does this model have a relationship for a given field? |
||
23 | * |
||
24 | * @param string $attribute |
||
25 | * @return boolean |
||
26 | * @author Ronan Chilvers <[email protected]> |
||
27 | */ |
||
28 | public function hasRelation($attribute) |
||
29 | { |
||
30 | $method = $this->getRelationMethod($attribute); |
||
31 | |||
32 | return method_exists($this, $method); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Get the relation for a given attribute |
||
37 | * |
||
38 | * @param string $attribute The attribute to check for a relationship |
||
39 | * @author Ronan Chilvers <[email protected]> |
||
40 | */ |
||
41 | 1 | public function getRelation($attribute) |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Create a relationship method for a given attribute name |
||
53 | * |
||
54 | * @param string |
||
55 | * @return string |
||
56 | * @author Ronan Chilvers <[email protected]> |
||
57 | */ |
||
58 | 1 | protected function getRelationMethod($attribute) |
|
65 |