Skip to content

Commit

Permalink
chore: superman can see every User & jamaah
Browse files Browse the repository at this point in the history
  • Loading branch information
KingSit3 committed Oct 27, 2024
1 parent 1dfcd7d commit cd8b583
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
36 changes: 26 additions & 10 deletions app/Filament/Superman/Resources/JamaahResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Filters;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
Expand All @@ -19,31 +20,46 @@ class JamaahResource extends Resource

protected static ?string $navigationIcon = 'heroicon-o-users';
protected static ?string $navigationLabel = 'Jamaah';
protected static ?string $pluralLabel = 'Jamaah';

public static function form(Form $form): Form
{
return $form
->schema([
//
]);
Forms\Components\TextInput::make('name')->required(),
Forms\Components\TextInput::make('website')
->suffix('.jamaah.com')
->prefixIcon('heroicon-m-globe-alt')
->required()
->alphaDash()
->unique(table: Jamaah::class, column: "website", ignoreRecord: true),
Forms\Components\Select::make("type")->options([
'masjid' => 'Masjid',
'majelis' => 'Majelis',
])
->selectablePlaceholder(false)
->required()

])->columns(1);
}

public static function table(Table $table): Table
{
return $table
->columns([
//
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('website'),
Tables\Columns\TextColumn::make('type'),
])
->filters([
//
Filters\SelectFilter::make('type')
->options([
'masjid' => 'Masjid',
'majelis' => 'Majelis',
])
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
Tables\Actions\DeleteAction::make(),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
class CreateJamaah extends CreateRecord
{
protected static string $resource = JamaahResource::class;
protected static bool $canCreateAnother = false;
}
20 changes: 10 additions & 10 deletions app/Filament/Superman/Resources/UsersResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Filament\Superman\Resources\UsersResource\RelationManagers;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
Expand All @@ -24,26 +23,27 @@ public static function form(Form $form): Form
{
return $form
->schema([
Select::make('roles')->multiple()->relationship('roles', 'name')
]);
Forms\Components\TextInput::make('name')->required(),
Forms\Components\Select::make('roles')
->relationship('roles', 'name')
->selectablePlaceholder(false)
->required()
])->columns(1);
}

public static function table(Table $table): Table
{
return $table
->columns([
//
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')->label("Register date"),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
Tables\Actions\DeleteAction::make(),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
class CreateUsers extends CreateRecord
{
protected static string $resource = UsersResource::class;
protected static bool $canCreateAnother = false;
}

0 comments on commit cd8b583

Please sign in to comment.