-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * wip * Policy * Update RosterUpdatePolicy.php
- Loading branch information
1 parent
3ad7f49
commit 2d13356
Showing
12 changed files
with
399 additions
and
13 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
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,82 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\RosterUpdates\Pages\ListRosterUpdates; | ||
use App\Filament\Resources\RosterUpdates\Pages\ViewRosterUpdate; | ||
use App\Models\RosterUpdate; | ||
use App\Models\Training\WaitingList; | ||
use Filament\Forms\Components\DatePicker; | ||
use Filament\Forms\Components\Section; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables\Actions\ViewAction; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Table; | ||
|
||
class RosterUpdateResource extends Resource | ||
{ | ||
protected static ?string $model = RosterUpdate::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-list-bullet'; | ||
|
||
protected static ?string $navigationGroup = 'User Management'; | ||
|
||
protected static ?int $navigationSort = 2; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Section::make('Details')->schema([ | ||
DatePicker::make('created_at')->label('Ran'), | ||
DatePicker::make('period_start'), | ||
DatePicker::make('period_end'), | ||
]), | ||
Section::make('Data') | ||
->statePath('data') | ||
->schema([ | ||
TextInput::make('meetHourRequirement')->label('Controllers meeting requirement'), | ||
TextInput::make('ganderControllers')->label('Eligible Gander/Oceanic controllers'), | ||
TextInput::make('removeFromRoster')->label('Removed from roster'), | ||
TextInput::make('homeRemovals')->label('Home members removed from roster'), | ||
TextInput::make('visitingAndTransferringRemovals')->label('V/T removed from roster'), | ||
TextInput::make('removeFromWaitingList')->label('Removed from waiting lists') | ||
->formatStateUsing(fn ($state) => collect($state)->map(function ($value, $key) { | ||
$waitingList = WaitingList::withTrashed()->where('id', '=', $key)?->first(); | ||
|
||
return "$waitingList?->name: $value"; | ||
})->implode('; ')), | ||
]), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('created_at')->label('Ran'), | ||
TextColumn::make('period_start'), | ||
TextColumn::make('period_end'), | ||
]) | ||
->actions([ | ||
ViewAction::make(), | ||
])->defaultSort('created_at', 'DESC'); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => ListRosterUpdates::route('/'), | ||
'view' => ViewRosterUpdate::route('/{record}'), | ||
]; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/Filament/Resources/RosterUpdates/Pages/ListRosterUpdates.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,16 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\RosterUpdates\Pages; | ||
|
||
use App\Filament\Helpers\Pages\BaseListRecordsPage; | ||
use App\Filament\Resources\RosterUpdateResource; | ||
|
||
class ListRosterUpdates extends BaseListRecordsPage | ||
{ | ||
protected static string $resource = RosterUpdateResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return []; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/Filament/Resources/RosterUpdates/Pages/ViewRosterUpdate.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,16 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\RosterUpdates\Pages; | ||
|
||
use App\Filament\Helpers\Pages\BaseViewRecordPage; | ||
use App\Filament\Resources\RosterUpdateResource; | ||
|
||
class ViewRosterUpdate extends BaseViewRecordPage | ||
{ | ||
protected static string $resource = RosterUpdateResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return []; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
|
||
class RosterUpdate extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = ['period_start', 'period_end', 'data']; | ||
|
||
protected $casts = [ | ||
'data' => 'json', | ||
]; | ||
} |
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 | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\Mship\Account; | ||
use App\Models\RosterUpdate; | ||
|
||
class RosterUpdatePolicy | ||
{ | ||
/** | ||
* Determine whether the user can view any models. | ||
*/ | ||
public function viewAny(Account $account): bool | ||
{ | ||
return $account->can('roster.manage'); | ||
} | ||
|
||
/** | ||
* Determine whether the user can view the model. | ||
*/ | ||
public function view(Account $account, RosterUpdate $rosterUpdate): bool | ||
{ | ||
return $account->can('roster.manage'); | ||
} | ||
|
||
/** | ||
* Determine whether the user can create models. | ||
*/ | ||
public function create(Account $account): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can update the model. | ||
*/ | ||
public function update(Account $account, RosterUpdate $rosterUpdate): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can delete the model. | ||
*/ | ||
public function delete(Account $account, RosterUpdate $rosterUpdate): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can restore the model. | ||
*/ | ||
public function restore(Account $account, RosterUpdate $rosterUpdate): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can permanently delete the model. | ||
*/ | ||
public function forceDelete(Account $account, RosterUpdate $rosterUpdate): bool | ||
{ | ||
return false; | ||
} | ||
} |
Oops, something went wrong.