Skip to content

Commit

Permalink
Merge pull request #22 from Steinbeck-Lab/functionality-button-for-pu…
Browse files Browse the repository at this point in the history
…blishing-collection

Functionality button for publishing collection
  • Loading branch information
CS76 authored May 15, 2024
2 parents 220a730 + e14219b commit a608aca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Filament/Dashboard/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public static function table(Table $table): Table
return $table
->columns([
Tables\Columns\TextColumn::make('title')->wrap(),
Tables\Columns\TextColumn::make('status')
->badge()
->color(fn (string $state): string => match ($state) {
'DRAFT' => 'info',
'REVIEW' => 'warning',
'EMBARGO' => 'warning',
'PUBLISHED' => 'success',
'REJECTED' => 'danger',
}),
])
->filters([
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ public function table(Table $table): Table
->action(function () {
Artisan::call('entries:process');
}),
Action::make('publish')
->hidden(function () {
return $this->ownerRecord->molecules()->where('status', 'DRAFT')->count() < 1;
})
->action(function () {
$this->ownerRecord->status = 'PUBLISHED';
$this->ownerRecord->is_public = true;
$this->ownerRecord->molecules()->where('status', 'DRAFT')->update(['status' => 'APPROVED']);
$this->ownerRecord->save();
}),
// Tables\Actions\CreateAction::make(),
])
->actions([
Expand Down

0 comments on commit a608aca

Please sign in to comment.