Skip to content

Commit cd75168

Browse files
scott graysonscott grayson
authored andcommitted
2 parents 7731ba0 + 4d8956b commit cd75168

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/Resources/RelationManagers/LibraryItemPermissionsRelationManager.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tapp\FilamentLibrary\Resources\RelationManagers;
44

5+
use App\Models\User;
56
use Filament\Actions\BulkActionGroup;
67
use Filament\Actions\CreateAction;
78
use Filament\Actions\DeleteAction;
@@ -15,7 +16,6 @@
1516
use Illuminate\Database\Eloquent\Model;
1617
use Illuminate\Support\Facades\Schema as SchemaFacade;
1718
use Tapp\FilamentLibrary\Models\LibraryItemPermission;
18-
use App\Models\User;
1919

2020
class 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

Comments
 (0)