@@ -11,17 +11,18 @@ trait HasTitleMenuLabelTrait
11
11
public function getMenuLabel (?string $ locale = null ): string
12
12
{
13
13
$ locale = $ locale ?: app ()->getLocale ();
14
-
14
+
15
15
// Check if the model uses translations (like Spatie Laravel Translatable)
16
16
if (method_exists ($ this , 'getTranslation ' )) {
17
17
$ title = $ this ->getTranslation ('title ' , $ locale );
18
18
if (empty ($ title )) {
19
19
// Fallback to the configured fallback locale
20
20
$ title = $ this ->getTranslation ('title ' , config ('app.fallback_locale ' , 'en ' ));
21
21
}
22
+
22
23
return $ title ?: 'Untitled ' ;
23
24
}
24
-
25
+
25
26
return $ this ->title ?: 'Untitled ' ;
26
27
}
27
28
@@ -33,16 +34,16 @@ public function scopeSearchForMenuItems($query, string $search)
33
34
{
34
35
return $ query ->where (function ($ query ) use ($ search ) {
35
36
$ query ->where ('title ' , 'like ' , "% {$ search }% " );
36
-
37
+
37
38
// Add additional searchable fields if they exist
38
39
$ searchableFields = ['name ' , 'intro ' , 'description ' , 'overview_title ' ];
39
40
foreach ($ searchableFields as $ field ) {
40
- if (in_array ($ field , $ this ->getFillable ()) ||
41
- (method_exists ($ this , 'getTranslatableAttributes ' ) &&
41
+ if (in_array ($ field , $ this ->getFillable ()) ||
42
+ (method_exists ($ this , 'getTranslatableAttributes ' ) &&
42
43
in_array ($ field , $ this ->getTranslatableAttributes ()))) {
43
44
$ query ->orWhere ($ field , 'like ' , "% {$ search }% " );
44
45
}
45
46
}
46
47
});
47
48
}
48
- }
49
+ }
0 commit comments