wip
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\Users\Schemas;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserForm
|
||||
@@ -29,7 +30,6 @@ class UserForm
|
||||
|
||||
TextInput::make('phone')
|
||||
->label(__('Phone number'))
|
||||
->required()
|
||||
->unique(ignoreRecord: true),
|
||||
|
||||
TextInput::make('email')
|
||||
@@ -51,6 +51,14 @@ class UserForm
|
||||
->preload()
|
||||
->native(false)
|
||||
->required(),
|
||||
|
||||
Select::make('branches')
|
||||
->label(__('Branches'))
|
||||
->relationship('branches', 'name', fn (Builder $query) => $query->distinct('id')->orderBy('id'))
|
||||
->multiple()
|
||||
->preload()
|
||||
->native(false)
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ class UsersTable
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', direction: 'desc')
|
||||
->columns([
|
||||
TextColumn::make('id'),
|
||||
|
||||
TextColumn::make('first_name')
|
||||
->label(__('First name'))
|
||||
->searchable()
|
||||
|
||||
@@ -16,12 +16,31 @@ use Filament\Tables\Table;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUsers;
|
||||
|
||||
protected static string|BackedEnum|null $activeNavigationIcon = Heroicon::Users;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'first_name';
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('Users');
|
||||
}
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return __('User');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return __('Users');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return UserForm::configure($schema);
|
||||
|
||||
Reference in New Issue
Block a user