-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddba6af
commit efc45ea
Showing
4 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\UserResource\Pages; | ||
use App\Filament\Resources\UserResource\RelationManagers; | ||
use App\Models\User; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\SoftDeletingScope; | ||
|
||
class UserResource extends Resource | ||
{ | ||
protected static ?string $model = User::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('uuid') | ||
->label('UUID') | ||
->maxLength(36), | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('email') | ||
->email() | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('password') | ||
->password() | ||
->required() | ||
->maxLength(60), | ||
Forms\Components\TextInput::make('github_id') | ||
->numeric(), | ||
Forms\Components\TextInput::make('github_username') | ||
->maxLength(255), | ||
Forms\Components\Toggle::make('is_sponsor'), | ||
Forms\Components\TextInput::make('avatar') | ||
->maxLength(255), | ||
Forms\Components\Toggle::make('is_admin') | ||
->required(), | ||
Forms\Components\DateTimePicker::make('next_purchase_discount_period_ends_at'), | ||
Forms\Components\DateTimePicker::make('sponsor_gift_given_at'), | ||
Forms\Components\Toggle::make('has_access_to_unreleased_products') | ||
->required(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('avatar') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('name') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('email') | ||
->searchable(), | ||
Tables\Columns\CheckboxColumn::make('is_sponsor'), | ||
Tables\Columns\CheckboxColumn::make('is_admin'), | ||
Tables\Columns\CheckboxColumn::make('has_access_to_unreleased_products'), | ||
|
||
Tables\Columns\TextColumn::make('created_at') | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListUsers::route('/'), | ||
'create' => Pages\CreateUser::route('/create'), | ||
'edit' => Pages\EditUser::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\UserResource\Pages; | ||
|
||
use App\Filament\Resources\UserResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateUser extends CreateRecord | ||
{ | ||
protected static string $resource = UserResource::class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\UserResource\Pages; | ||
|
||
use App\Filament\Resources\UserResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditUser extends EditRecord | ||
{ | ||
protected static string $resource = UserResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\UserResource\Pages; | ||
|
||
use App\Filament\Resources\UserResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListUsers extends ListRecords | ||
{ | ||
protected static string $resource = UserResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |