Skip to content

Commit dce608e

Browse files
committed
Add more tests; Add filter in filament resource; Added options for user create command
1 parent 84c9cfe commit dce608e

File tree

20 files changed

+413
-12
lines changed

20 files changed

+413
-12
lines changed

app/Console/Commands/Admin/UserCreateCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class UserCreateCommand extends Command
2222
protected $signature = 'admin:user:create
2323
{ name : The name of the user }
2424
{ email : The email of the user }
25-
{ --ask-for-password : Ask for the password, otherwise the command will generate a random one }';
25+
{ --ask-for-password : Ask for the password, otherwise the command will generate a random one }
26+
{ --verify-email : Verify the email address of the user }';
2627

2728
/**
2829
* The console command description.
@@ -39,6 +40,7 @@ public function handle(): int
3940
$name = $this->argument('name');
4041
$email = $this->argument('email');
4142
$askForPassword = (bool) $this->option('ask-for-password');
43+
$verifyEmail = (bool) $this->option('verify-email');
4244

4345
if (User::query()->where('email', $email)->where('is_placeholder', '=', false)->exists()) {
4446
$this->error('User with email "'.$email.'" already exists.');
@@ -71,6 +73,10 @@ public function handle(): int
7173
throw new LogicException('User does not have an organization');
7274
}
7375

76+
if ($verifyEmail) {
77+
$user->markEmailAsVerified();
78+
}
79+
7480
$this->info('Created user "'.$name.'" ("'.$email.'")');
7581
$this->line('ID: '.$user->getKey());
7682
$this->line('Name: '.$name);

app/Filament/Resources/ClientResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ public static function table(Table $table): Table
6060
->defaultSort('created_at', 'desc')
6161
->filters([
6262
SelectFilter::make('organization')
63+
->label('Organization')
6364
->relationship('organization', 'name')
6465
->searchable(),
66+
SelectFilter::make('organization_id')
67+
->label('Organization ID')
68+
->relationship('organization', 'id')
69+
->searchable(),
6570
])
6671
->actions([
6772
Tables\Actions\EditAction::make(),

app/Filament/Resources/OrganizationInvitationResource/Pages/EditOrganizationInvitation.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Filament\Resources\OrganizationInvitationResource\Pages;
66

77
use App\Filament\Resources\OrganizationInvitationResource;
8+
use Filament\Actions;
89
use Filament\Resources\Pages\EditRecord;
910

1011
class EditOrganizationInvitation extends EditRecord
@@ -14,6 +15,8 @@ class EditOrganizationInvitation extends EditRecord
1415
protected function getHeaderActions(): array
1516
{
1617
return [
18+
Actions\DeleteAction::make()
19+
->icon('heroicon-m-trash'),
1720
];
1821
}
1922
}

app/Filament/Resources/OrganizationResource/RelationManagers/UsersRelationManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function table(Table $table): Table
5656
])
5757
->headerActions([
5858
Tables\Actions\AttachAction::make()
59+
->recordTitle(fn (User $record): string => "{$record->name} ({$record->email})")
5960
->form(fn (AttachAction $action): array => [
6061
$action->getRecordSelect(),
6162
Select::make('role')

app/Filament/Resources/ProjectResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ public static function table(Table $table): Table
7272
])
7373
->filters([
7474
SelectFilter::make('organization')
75+
->label('Organization')
7576
->relationship('organization', 'name')
7677
->searchable(),
78+
SelectFilter::make('organization_id')
79+
->label('Organization ID')
80+
->relationship('organization', 'id')
81+
->searchable(),
7782
])
7883
->defaultSort('created_at', 'desc')
7984
->actions([

app/Filament/Resources/ReportResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ public static function table(Table $table): Table
101101
->defaultSort('created_at', 'desc')
102102
->filters([
103103
SelectFilter::make('organization')
104+
->label('Organization')
104105
->relationship('organization', 'name')
105106
->searchable(),
107+
SelectFilter::make('organization_id')
108+
->label('Organization ID')
109+
->relationship('organization', 'id')
110+
->searchable(),
106111
])
107112
->actions([
108113
Action::make('public-view')

app/Filament/Resources/TagResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ public static function table(Table $table): Table
6060
->defaultSort('created_at', 'desc')
6161
->filters([
6262
SelectFilter::make('organization')
63+
->label('Organization')
6364
->relationship('organization', 'name')
6465
->searchable(),
66+
SelectFilter::make('organization_id')
67+
->label('Organization ID')
68+
->relationship('organization', 'id')
69+
->searchable(),
6570
])
6671
->actions([
6772
Tables\Actions\EditAction::make(),

app/Filament/Resources/TaskResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ public static function table(Table $table): Table
6161
])
6262
->filters([
6363
SelectFilter::make('organization')
64+
->label('Organization')
6465
->relationship('organization', 'name')
6566
->searchable(),
67+
SelectFilter::make('organization_id')
68+
->label('Organization ID')
69+
->relationship('organization', 'id')
70+
->searchable(),
6671
])
6772
->defaultSort('created_at', 'desc')
6873
->actions([

app/Filament/Resources/TimeEntryResource.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ public static function table(Table $table): Table
9292
])
9393
->filters([
9494
SelectFilter::make('organization')
95+
->label('Organization')
9596
->relationship('organization', 'name')
9697
->searchable(),
98+
SelectFilter::make('organization_id')
99+
->label('Organization ID')
100+
->relationship('organization', 'id')
101+
->searchable(),
97102
])
98103
->defaultSort('created_at', 'desc')
99104
->actions([

app/Service/Import/ImportDatabaseHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public function getCachedModels(): array
196196
if ($this->mapKeyToModel === null) {
197197
return [];
198198
}
199+
199200
return array_values($this->mapKeyToModel);
200201
}
201202

0 commit comments

Comments
 (0)