-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
9 changed files
with
224 additions
and
16 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
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,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\CountyResource\Pages; | ||
use App\Models\County; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Table; | ||
|
||
class CountyResource extends Resource | ||
{ | ||
protected static ?string $model = County::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
protected static bool $isScopedToTenant = false; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('id') | ||
->label(__('admin.field.siruta')) | ||
->unique(ignoreRecord: true) | ||
->required(), | ||
|
||
TextInput::make('name') | ||
->label(__('admin.field.name')) | ||
->required(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('id') | ||
->label(__('admin.field.siruta')) | ||
->sortable() | ||
->shrink(), | ||
|
||
TextColumn::make('name') | ||
->label(__('admin.field.name')) | ||
->searchable() | ||
->sortable(), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ManageCounties::route('/'), | ||
]; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/Filament/Resources/CountyResource/Pages/ManageCounties.php
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\CountyResource\Pages; | ||
|
||
use App\Filament\Resources\CountyResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ManageRecords; | ||
|
||
class ManageCounties extends ManageRecords | ||
{ | ||
protected static string $resource = CountyResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::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,103 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\LocalityResource\Pages; | ||
use App\Models\Locality; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Filters\SelectFilter; | ||
use Filament\Tables\Table; | ||
|
||
class LocalityResource extends Resource | ||
{ | ||
protected static ?string $model = Locality::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
protected static bool $isScopedToTenant = false; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Select::make('county_id') | ||
->relationship('county', 'name') | ||
->required(), | ||
|
||
TextInput::make('level') | ||
->required() | ||
->numeric(), | ||
|
||
TextInput::make('type') | ||
->required() | ||
->numeric(), | ||
|
||
TextInput::make('parent_id') | ||
->numeric(), | ||
|
||
TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('id') | ||
->label(__('admin.field.siruta')) | ||
->sortable(), | ||
|
||
TextColumn::make('name') | ||
->label(__('admin.field.name')) | ||
->searchable() | ||
->sortable(), | ||
|
||
TextColumn::make('level') | ||
->numeric() | ||
->sortable(), | ||
|
||
TextColumn::make('type') | ||
->numeric() | ||
->sortable(), | ||
|
||
TextColumn::make('parent.name') | ||
->sortable(), | ||
|
||
TextColumn::make('county.name') | ||
->label(__('admin.field.county')) | ||
->searchable() | ||
->sortable(), | ||
|
||
]) | ||
->filters([ | ||
SelectFilter::make('county') | ||
->relationship('county', 'name') | ||
->label(__('admin.field.county')), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ManageLocalities::route('/'), | ||
]; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/Filament/Resources/LocalityResource/Pages/ManageLocalities.php
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\LocalityResource\Pages; | ||
|
||
use App\Filament\Resources\LocalityResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ManageRecords; | ||
|
||
class ManageLocalities extends ManageRecords | ||
{ | ||
protected static string $resource = LocalityResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::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
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
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
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