22
33namespace Tapp \FilamentLibrary \Resources \RelationManagers ;
44
5+ use App \Models \User ;
56use Filament \Actions \BulkActionGroup ;
67use Filament \Actions \CreateAction ;
78use Filament \Actions \DeleteAction ;
1516use Illuminate \Database \Eloquent \Model ;
1617use Illuminate \Support \Facades \Schema as SchemaFacade ;
1718use Tapp \FilamentLibrary \Models \LibraryItemPermission ;
18- use App \Models \User ;
1919
2020class LibraryItemPermissionsRelationManager extends RelationManager
2121{
@@ -27,11 +27,10 @@ class LibraryItemPermissionsRelationManager extends RelationManager
2727
2828 protected static ?string $ pluralModelLabel = 'Permissions ' ;
2929
30-
3130 public static function canAccess (): bool
3231 {
3332 $ user = auth ()->user ();
34- if (!$ user ) {
33+ if (! $ user ) {
3534 return false ;
3635 }
3736
@@ -59,7 +58,7 @@ public static function canViewForRecord(Model $ownerRecord, string $pageClass):
5958 */
6059 private function getUserDisplayName ($ user ): string
6160 {
62- if (!$ user ) {
61+ if (! $ user ) {
6362 return 'Unknown User ' ;
6463 }
6564
@@ -91,12 +90,12 @@ public function form(Schema $schema): Schema
9190 ->label ('User ' )
9291 ->searchable ()
9392 ->preload ()
94- ->getSearchResultsUsing (fn ( string $ search ): array =>
95- User::where (function ($ query ) use ($ search ) {
93+ ->getSearchResultsUsing (
94+ fn ( string $ search ): array => User::where (function ($ query ) use ($ search ) {
9695 // Search first_name and last_name fields if they exist
9796 if (SchemaFacade::hasColumn ('users ' , 'first_name ' ) && SchemaFacade::hasColumn ('users ' , 'last_name ' )) {
9897 $ query ->orWhere ('first_name ' , 'like ' , "% {$ search }% " )
99- ->orWhere ('last_name ' , 'like ' , "% {$ search }% " );
98+ ->orWhere ('last_name ' , 'like ' , "% {$ search }% " );
10099 }
101100 // Search name field if it exists and first/last don't
102101 elseif (SchemaFacade::hasColumn ('users ' , 'name ' )) {
@@ -105,15 +104,15 @@ public function form(Schema $schema): Schema
105104 // Always search email
106105 $ query ->orWhere ('email ' , 'like ' , "% {$ search }% " );
107106 })
108- ->limit (50 )
109- ->get ()
110- ->mapWithKeys (fn ($ user ) => [
111- $ user ->id => $ this ->getUserDisplayName ($ user )
112- ])
113- ->toArray ()
107+ ->limit (50 )
108+ ->get ()
109+ ->mapWithKeys (fn ($ user ) => [
110+ $ user ->id => $ this ->getUserDisplayName ($ user ),
111+ ])
112+ ->toArray ()
114113 )
115- ->getOptionLabelUsing (fn ( $ value ): ? string =>
116- $ this ->getUserDisplayName (User::find ($ value ))
114+ ->getOptionLabelUsing (
115+ fn ( $ value ): ? string => $ this ->getUserDisplayName (User::find ($ value ))
117116 )
118117 ->required (),
119118
@@ -137,7 +136,7 @@ public function table(Table $table): Table
137136 // Search first_name and last_name fields if they exist
138137 if (SchemaFacade::hasColumn ('users ' , 'first_name ' ) && SchemaFacade::hasColumn ('users ' , 'last_name ' )) {
139138 $ query ->orWhere ('first_name ' , 'like ' , "% {$ search }% " )
140- ->orWhere ('last_name ' , 'like ' , "% {$ search }% " );
139+ ->orWhere ('last_name ' , 'like ' , "% {$ search }% " );
141140 }
142141 // Search name field if it exists and first/last don't
143142 elseif (SchemaFacade::hasColumn ('users ' , 'name ' )) {
0 commit comments