Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/Filament/Pages/Tenancy/EditTeamProfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace App\Filament\Pages\Tenancy;

use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\EditTenantProfile;

class EditTeamProfile extends EditTenantProfile
{
public static function getLabel(): string
{
return 'Team profile';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
TextInput::make('slug'),
]);
}
}
33 changes: 33 additions & 0 deletions app/Filament/Pages/Tenancy/RegisterTeam.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
namespace App\Filament\Pages\Tenancy;

use App\Models\Team;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant;

class RegisterTeam extends RegisterTenant
{
public static function getLabel(): string
{
return 'Register team';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
TextInput::make('slug'),
]);
}

protected function handleRegistration(array $data): Team
{
$team = Team::create($data);

$team->members()->attach(auth()->user());

return $team;
}
}
95 changes: 95 additions & 0 deletions app/Filament/Resources/AssociationResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\AssociationResource\Pages;
use App\Filament\Resources\AssociationResource\RelationManagers;
use App\Models\Association;
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 AssociationResource extends Resource
{
protected static ?string $model = Association::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
{
return $form
->schema([
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(255),
Forms\Components\TextInput::make('password_confirmation')
->password()
->required()
->maxLength(255)
->same('password')
->label('Confirm Password'),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable(),
Tables\Columns\TextColumn::make('email')
->searchable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_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\ListAssociations::route('/'),
'create' => Pages\CreateAssociation::route('/create'),
'edit' => Pages\EditAssociation::route('/{record}/edit'),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\Resources\AssociationResource\Pages;

use App\Filament\Resources\AssociationResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateAssociation extends CreateRecord
{
protected static string $resource = AssociationResource::class;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Resources\AssociationResource\Pages;

use App\Filament\Resources\AssociationResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditAssociation extends EditRecord
{
protected static string $resource = AssociationResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Resources\AssociationResource\Pages;

use App\Filament\Resources\AssociationResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListAssociations extends ListRecords
{
protected static string $resource = AssociationResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
7 changes: 6 additions & 1 deletion app/Filament/Resources/CityResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ class CityResource extends Resource
protected static ?string $model = City::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'System Management';
protected static ?string $navigationGroup = 'إعدادت النظام';
protected static ?string $navigationLabel = 'المدن';
protected static ?string $pluralModelLabel = 'مدن';
protected static ?string $modelLabel = 'مدينة';



public static function form(Form $form): Form
{
Expand Down
3 changes: 2 additions & 1 deletion app/Filament/Resources/CountryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
//
RelationManagers\StatesRelationManager::class
];
}


public static function getPages(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Filament\Resources\CountryResource\RelationManagers;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class StatesRelationManager extends RelationManager
{
protected static string $relationship = 'states';

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
Tables\Columns\TextColumn::make('name'),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}
14 changes: 13 additions & 1 deletion app/Filament/Resources/DepartmentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Infolists\InfoList;
use Filament\Infolists\Components\TextEntry;

class DepartmentResource extends Resource
{
Expand Down Expand Up @@ -72,8 +74,18 @@ public static function getPages(): array
return [
'index' => Pages\ListDepartments::route('/'),
'create' => Pages\CreateDepartment::route('/create'),
'view' => Pages\ViewDepartment::route('/{record}'),
//'view' => Pages\ViewDepartment::route('/{record}'),
'edit' => Pages\EditDepartment::route('/{record}/edit'),
];
}


public static function infolist(InfoList $infolist): InfoList
{
return $infolist
->schema([
TextEntry::make('name'),
TextEntry::make('employees_count'),
]);
}
}
Loading