File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -10,20 +10,25 @@ trait HasAlternatesThroughRewrites
10
10
protected function alternates (): Attribute
11
11
{
12
12
return Attribute::make (
13
- get: fn () => $ this
14
- ->rewrites ()
15
- ->where ('redirect_type ' , 0 )
16
- ->whereHas ('store ' , fn ($ query ) => $ query ->where ('store.group_id ' , config ('rapidez.group ' )))
17
- ->whereNot ('store_id ' , config ('rapidez.store ' ))
18
- ->pluck ('request_path ' , 'store_id ' )
19
- ->mapWithKeys (function ($ url , $ storeId ) {
13
+ get: function () {
14
+ $ rewrites = $ this ->rewrites ()
15
+ ->where ('redirect_type ' , 0 )
16
+ ->whereHas ('store ' , fn ($ query ) => $ query ->where ('store.group_id ' , config ('rapidez.group ' )))
17
+ ->pluck ('request_path ' , 'store_id ' );
18
+
19
+ if (! $ rewrites ->keys ()->contains (fn ($ store ) => $ store !== config ('rapidez.store ' ))) {
20
+ return collect ();
21
+ }
22
+
23
+ return $ rewrites ->mapWithKeys (function ($ url , $ storeId ) {
20
24
return Rapidez::withStore ($ storeId , function () use ($ url ) {
21
25
$ locale = str (Rapidez::config ('general/locale/code ' , 'en_US ' ))->replace ('_ ' , '- ' )->lower ()->value ();
22
26
$ url = Rapidez::config ('web/secure/base_url ' ) . $ url ;
23
27
24
28
return [$ locale => $ url ];
25
29
});
26
- })
30
+ });
31
+ }
27
32
);
28
33
}
29
34
}
You can’t perform that action at this time.
0 commit comments