File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,36 @@ class Link extends Model {
8
8
protected $ fillable = ['url ' , 'display ' , 'show_menu ' ];
9
9
10
10
protected $ table = 'links ' ;
11
+
12
+ static $ cache = [];
13
+ public static function getAllLinks ($ forceRefresh = false ) // allCached(
14
+ {
15
+ if (!isset (self ::$ cache ['all ' ]) || $ forceRefresh ) {
16
+ self ::$ cache ['all ' ] = Link::all ();
17
+ }
18
+ return self ::$ cache ['all ' ];
19
+ }
20
+ public static function getUrls ($ forceRefresh = false ) // returnUrls(
21
+ {
22
+ if (!isset (self ::$ cache ['all_urls ' ]) || $ forceRefresh ) {
23
+ $ configs = Link::allCached ($ forceRefresh );
24
+ self ::$ cache ['all_urls ' ] = $ configs ->pluck ('url ' )->toArray ();
25
+ }
26
+ return self ::$ cache ['all_urls ' ];
27
+ }
28
+ public static function getMainUrls ($ forceRefresh = false )
29
+ {
30
+ if (!isset (self ::$ cache ['main_urls ' ]) || $ forceRefresh ) {
31
+ $ configs = Link::where ('main ' , '= ' , true )->get (['url ' ]);
32
+ self ::$ cache ['main_urls ' ] = $ configs ->pluck ('url ' )->toArray ();
33
+ }
34
+ return self ::$ cache ['main_urls ' ];
35
+ }
36
+ public function addNewLink ($ url , $ label , $ visibility ) // getAndSave(
37
+ {
38
+ $ this ->url = $ url ;
39
+ $ this ->display = $ label ;
40
+ $ this ->show_menu = $ visibility ;
41
+ $ this ->save ();
42
+ }
11
43
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public function roles()
19
19
return $ this ->belongsToMany (Role::class);
20
20
}
21
21
22
- public function getAndSave ($ url , $ label ){
22
+ public function getAndSave ($ name , $ label ){
23
23
$ this ->name = $ name ;
24
24
$ this ->label = $ label ;
25
25
$ this ->save ();
You can’t perform that action at this time.
0 commit comments