File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ Check MD [online][check-online].
99
1010## [ unreleased]
1111
12+ ## [ 1.7.0] - 2021-09-29
13+
14+ ### Added
15+
16+ - Add model's trait ` DeferredRelations ` :
17+
1218## [ 1.6.0] - 2021-08-27
1319
1420### Added
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Php \Support \Laravel \Traits \Models ;
6+
7+ use Illuminate \Database \Eloquent \Model ;
8+
9+ /**
10+ * @mixin Model
11+ */
12+ trait DeferredRelations
13+ {
14+ protected static array $ deferredRelations = [];
15+
16+ public static function addDeferredRelation (string $ relation , mixed $ callback ): void
17+ {
18+ self ::$ deferredRelations [$ relation ] = $ callback ;
19+ }
20+
21+ public static function getDeferredRelation (string $ relation ): mixed
22+ {
23+ return self ::$ deferredRelations [$ relation ];
24+ }
25+
26+ public static function getDeferredRelations (): array
27+ {
28+ return self ::$ deferredRelations ;
29+ }
30+
31+ public static function unsetDeferredRelation ($ relation ): void
32+ {
33+ unset(self ::$ deferredRelations [$ relation ]);
34+ }
35+
36+ public static function unsetDeferredRelations (): void
37+ {
38+ self ::$ deferredRelations = [];
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments