Skip to content

Commit

Permalink
use states history for state relation manager
Browse files Browse the repository at this point in the history
  • Loading branch information
atoff committed Nov 19, 2023
1 parent 89e7ec5 commit e050903
Showing 1 changed file with 12 additions and 1 deletion.
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 e050903

Please sign in to comment.