-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from canyongbs/feature/fdw-case-model-and-fila…
…ment-setup [Feature] Case Model and filament setup
- Loading branch information
Showing
38 changed files
with
781 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum ColumnColorOptions: string | ||
{ | ||
case SUCCESS = 'success'; | ||
|
||
case DANGER = 'danger'; | ||
|
||
case WARNING = 'warning'; | ||
|
||
case INFO = 'info'; | ||
|
||
case PRIMARY = 'primary'; | ||
|
||
case GRAY = 'gray'; | ||
} |
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,80 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use Filament\Tables; | ||
use Filament\Forms\Form; | ||
use Filament\Tables\Table; | ||
use App\Models\CaseItemPriority; | ||
use Filament\Resources\Resource; | ||
use Filament\Forms\Components\TextInput; | ||
use App\Filament\Resources\CaseItemPriorityResource\Pages; | ||
|
||
class CaseItemPriorityResource extends Resource | ||
{ | ||
protected static ?string $model = CaseItemPriority::class; | ||
|
||
protected static ?string $navigationGroup = 'Field Settings'; | ||
|
||
protected static ?int $navigationSort = 3; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-arrows-up-down'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('name') | ||
->label('Name') | ||
->required(), | ||
TextInput::make('order') | ||
->numeric() | ||
->label('Priority Order') | ||
->required() | ||
->disabledOn('edit'), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->label('Name') | ||
->searchable() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('order') | ||
->label('Priority Order') | ||
->sortable(), | ||
]) | ||
->defaultSort('order') | ||
->filters([ | ||
]) | ||
->actions([ | ||
Tables\Actions\ViewAction::make(), | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]) | ||
->reorderable('order'); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListCaseItemPriorities::route('/'), | ||
'create' => Pages\CreateCaseItemPriority::route('/create'), | ||
'view' => Pages\ViewCaseItemPriority::route('/{record}'), | ||
'edit' => Pages\EditCaseItemPriority::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/Filament/Resources/CaseItemPriorityResource/Pages/CreateCaseItemPriority.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,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemPriorityResource\Pages; | ||
|
||
use Filament\Resources\Pages\CreateRecord; | ||
use App\Filament\Resources\CaseItemPriorityResource; | ||
|
||
class CreateCaseItemPriority extends CreateRecord | ||
{ | ||
protected static string $resource = CaseItemPriorityResource::class; | ||
} |
20 changes: 20 additions & 0 deletions
20
app/Filament/Resources/CaseItemPriorityResource/Pages/EditCaseItemPriority.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,20 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemPriorityResource\Pages; | ||
|
||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
use App\Filament\Resources\CaseItemPriorityResource; | ||
|
||
class EditCaseItemPriority extends EditRecord | ||
{ | ||
protected static string $resource = CaseItemPriorityResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\ViewAction::make(), | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/CaseItemPriorityResource/Pages/ListCaseItemPriorities.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemPriorityResource\Pages; | ||
|
||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
use App\Filament\Resources\CaseItemPriorityResource; | ||
|
||
class ListCaseItemPriorities extends ListRecords | ||
{ | ||
protected static string $resource = CaseItemPriorityResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/CaseItemPriorityResource/Pages/ViewCaseItemPriority.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemPriorityResource\Pages; | ||
|
||
use Filament\Actions; | ||
use Filament\Resources\Pages\ViewRecord; | ||
use App\Filament\Resources\CaseItemPriorityResource; | ||
|
||
class ViewCaseItemPriority extends ViewRecord | ||
{ | ||
protected static string $resource = CaseItemPriorityResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\EditAction::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,128 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use Filament\Tables; | ||
use App\Models\Student; | ||
use App\Models\CaseItem; | ||
use Filament\Forms\Form; | ||
use Filament\Tables\Table; | ||
use App\Models\CaseItemStatus; | ||
use Filament\Resources\Resource; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Forms\Components\Textarea; | ||
use Filament\Forms\Components\TextInput; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Filament\Forms\Components\MorphToSelect; | ||
use App\Filament\Resources\CaseItemResource\Pages; | ||
|
||
class CaseItemResource extends Resource | ||
{ | ||
protected static ?string $model = CaseItem::class; | ||
|
||
protected static ?string $navigationGroup = 'Cases'; | ||
|
||
protected static ?int $navigationSort = 1; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-briefcase'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('casenumber') | ||
->label('Case #') | ||
->required() | ||
->disabledOn('edit'), | ||
MorphToSelect::make('respondent') | ||
->types([ | ||
MorphToSelect\Type::make(Student::class) | ||
->getOptionLabelFromRecordUsing(fn (Student $student): string => "{$student->first_name} {$student->middle_name} {$student->last_name}") | ||
->titleAttribute('first_name'), | ||
]) | ||
->searchable() | ||
->label('Respondent'), | ||
// TODO: Add Institution input | ||
Select::make('state') | ||
->options(CaseItemStatus::pluck('name', 'id')) | ||
->relationship('state', 'name') | ||
->label('State') | ||
->required(), | ||
// TODO: Add Type input | ||
Select::make('priority') | ||
->relationship( | ||
relationshipName: 'priority', | ||
titleAttribute: 'name', | ||
modifyOptionsQueryUsing: fn (Builder $query) => $query->orderBy('order'), | ||
) | ||
->label('Priority') | ||
->required(), | ||
Select::make('assignedTo') | ||
->relationship( | ||
relationshipName: 'assignedTo', | ||
titleAttribute: 'name', | ||
) | ||
->label('Assigned To') | ||
->required() | ||
->searchable(['name', 'email']), | ||
Textarea::make('close_details') | ||
->label('Close Details/Description') | ||
->nullable(), | ||
Textarea::make('res_details') | ||
->label('Internal Case Details') | ||
->nullable(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('casenumber') | ||
->label('Case #') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('priority.name') | ||
->label('Priority') | ||
->sortable(query: function (Builder $query, string $direction): Builder { | ||
return $query->orderByPowerJoins('priority.order', $direction); | ||
}), | ||
Tables\Columns\TextColumn::make('state.name') | ||
->label('Status') | ||
->badge() | ||
->color(fn (CaseItem $caseItem) => $caseItem->state->color), | ||
]) | ||
->filters([ | ||
Tables\Filters\SelectFilter::make('priority') | ||
->relationship('priority', 'name') | ||
->multiple(), | ||
Tables\Filters\SelectFilter::make('state') | ||
->relationship('state', 'name') | ||
->multiple(), | ||
]) | ||
->actions([ | ||
Tables\Actions\ViewAction::make(), | ||
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\ListCaseItems::route('/'), | ||
'create' => Pages\CreateCaseItem::route('/create'), | ||
'view' => Pages\ViewCaseItem::route('/{record}'), | ||
'edit' => Pages\EditCaseItem::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/Filament/Resources/CaseItemResource/Pages/CreateCaseItem.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,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemResource\Pages; | ||
|
||
use Filament\Resources\Pages\CreateRecord; | ||
use App\Filament\Resources\CaseItemResource; | ||
|
||
class CreateCaseItem extends CreateRecord | ||
{ | ||
protected static string $resource = CaseItemResource::class; | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/CaseItemResource/Pages/EditCaseItem.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemResource\Pages; | ||
|
||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
use App\Filament\Resources\CaseItemResource; | ||
|
||
class EditCaseItem extends EditRecord | ||
{ | ||
protected static string $resource = CaseItemResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/CaseItemResource/Pages/ListCaseItems.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemResource\Pages; | ||
|
||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
use App\Filament\Resources\CaseItemResource; | ||
|
||
class ListCaseItems extends ListRecords | ||
{ | ||
protected static string $resource = CaseItemResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Filament/Resources/CaseItemResource/Pages/ViewCaseItem.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,17 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CaseItemResource\Pages; | ||
|
||
use Filament\Resources\Pages\ViewRecord; | ||
use App\Filament\Resources\CaseItemResource; | ||
|
||
class ViewCaseItem extends ViewRecord | ||
{ | ||
protected static string $resource = CaseItemResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
]; | ||
} | ||
} |
Oops, something went wrong.