-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathFamilyResource.php
More file actions
152 lines (142 loc) · 5.07 KB
/
FamilyResource.php
File metadata and controls
152 lines (142 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
namespace App\Filament\App\Resources;
use Override;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\IconColumn;
use Filament\Actions\EditAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use App\Filament\App\Resources\FamilyResource\Pages\ListFamilies;
use App\Filament\App\Resources\FamilyResource\Pages\CreateFamily;
use App\Filament\App\Resources\FamilyResource\Pages\EditFamily;
use UnitEnum;
use BackedEnum;
use App\Filament\App\Resources\FamilyResource\Pages;
use App\Models\Family;
use Filament\Forms;
use Filament\Forms\Form;
use App\Filament\App\Resources\AppResource;
use Filament\Schemas\Schema;
use Filament\Tables;
use Filament\Actions;
use Filament\Tables\Table;
class FamilyResource extends AppResource
{
protected static ?string $model = Family::class;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-home';
protected static ?string $navigationLabel = 'Families';
protected static string | \UnitEnum | null $navigationGroup = '👥 Family Tree';
protected static ?int $navigationSort = 2;
#[Override]
public static function form(Schema $schema): Schema
{
return $schema
->components([
Section::make('Family Members')
->description('Identify the husband and wife in this family unit')
->icon('heroicon-o-users')
->columns(2)
->schema([
TextInput::make('husband_id')
->label('Husband ID')
->numeric(),
TextInput::make('wife_id')
->label('Wife ID')
->numeric(),
TextInput::make('nchi')
->label('Number of Children')
->maxLength(255),
TextInput::make('type_id')
->label('Family Type')
->numeric(),
Toggle::make('is_active')
->label('Active')
->default(true),
]),
Section::make('Notes')
->icon('heroicon-o-document-text')
->schema([
Textarea::make('description')
->maxLength(65535)
->columnSpanFull(),
]),
Section::make('Record References')
->icon('heroicon-o-hashtag')
->columns(2)
->collapsed()
->schema([
TextInput::make('chan')
->label('Change Date')
->maxLength(255),
TextInput::make('rin')
->label('RIN')
->maxLength(255),
]),
]);
}
#[Override]
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')
->label('ID')
->sortable(),
TextColumn::make('husband_id')
->label('Husband ID')
->numeric()
->sortable(),
TextColumn::make('wife_id')
->label('Wife ID')
->numeric()
->sortable(),
TextColumn::make('nchi')
->label('Children')
->searchable(),
IconColumn::make('is_active')
->label('Active')
->boolean(),
TextColumn::make('created_at')
->label('Created')
->since()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
TextColumn::make('updated_at')
->label('Updated')
->since()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TernaryFilter::make('is_active')
->label('Active'),
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
#[Override]
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListFamilies::route('/'),
'create' => CreateFamily::route('/create'),
'edit' => EditFamily::route('/{record}/edit'),
];
}
}