Skip to content

Commit

Permalink
fix: Use States History for Admin States Relation (#3342)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoff authored Nov 20, 2023
1 parent 89e7ec5 commit cb8f56b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2

- name: Install PHP dependencies
uses: ramsey/composer-install@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@

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

protected static ?string $recordTitleAttribute = 'id';

public function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('status')->badge()->getStateUsing(function ($record) {
if ($record->pivot->end_at) {
return 'Old';
}

return 'Active - '.($record->is_permanent ? 'Permenant' : 'Temporary');
})->color(fn (string $state): string => match ($state) {
'Old' => 'gray',
'Active - Permenant' => 'success',
'Active - Temporary' => 'success',
}),
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('pivot.region')->label('Region'),
Tables\Columns\TextColumn::make('pivot.division')->label('Divison'),
Expand Down

0 comments on commit cb8f56b

Please sign in to comment.