1 | <?php |
||
9 | class CachedRelationship |
||
10 | { |
||
11 | /** |
||
12 | * The Hash of the related entity |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $hash; |
||
17 | |||
18 | /** |
||
19 | * Pivot attributes, if any |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $pivotAttributes; |
||
24 | |||
25 | /** |
||
26 | * CachedRelationship constructor. |
||
27 | * @param $hash |
||
28 | * @param array $pivotAttributes |
||
29 | */ |
||
30 | public function __construct($hash, $pivotAttributes = []) |
||
31 | { |
||
32 | $this->hash = $hash; |
||
33 | $this->pivotAttributes = $pivotAttributes; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Return true if any pivot attributes are present |
||
38 | * |
||
39 | * @return boolean |
||
40 | */ |
||
41 | public function hasPivotAttributes() |
||
45 | |||
46 | /** |
||
47 | * Returns the hash of the related entity |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | public function getHash() |
||
55 | |||
56 | /** |
||
57 | * Get the cached values for the pivot attributes |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | public function getPivotAttributes() |
||
65 | |||
66 | /** |
||
67 | * Access to the hash for fast cache comparison |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | public function __toString() |
||
75 | } |
||
76 |