Skip to content

Commit

Permalink
Merge pull request #478 from OpenSynergic/fix--error-when-deleting-pa…
Browse files Browse the repository at this point in the history
…per-components

fix: error when deleting paper components
  • Loading branch information
rahmanramsi authored Dec 31, 2024
2 parents 534e48b + d901ecb commit 5081180
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/Models/SubmissionFileType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\EloquentSortable\SortableTrait;

class SubmissionFileType extends Model
Expand All @@ -16,4 +17,9 @@ class SubmissionFileType extends Model
'name',
'scheduled_conference_id',
];

public function files() : HasMany
{
return $this->hasMany(SubmissionFile::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function render()
public function table(Table $table): Table
{
return $table
->query(SubmissionFileType::query())
->query(SubmissionFileType::withCount(['files']))
->defaultPaginationPageOption(10)
->heading(__('general.paper_components'))
->reorderable('order_column')
Expand All @@ -39,6 +39,8 @@ public function table(Table $table): Table
TextColumn::make('name')
->label(__('general.name'))
->searchable(),
TextColumn::make('files_count')
->label(__('general.files')),
])
->headerActions([
CreateAction::make()
Expand All @@ -50,7 +52,8 @@ public function table(Table $table): Table
EditAction::make()
->modalWidth(MaxWidth::ExtraLarge)
->form(fn (Form $form) => $this->form($form)),
DeleteAction::make(),
DeleteAction::make()
->hidden(fn(SubmissionFileType $record) => $record->files_count > 0),
])
->bulkActions([
DeleteBulkAction::make(),
Expand Down
1 change: 1 addition & 0 deletions lang/en/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -993,4 +993,5 @@
'registration_setting.open_date' => 'Open Date',
'registration_setting.close_date' => 'Close Date',
'submission_setting.hide_from_timeline' => 'Hide from Timeline',
'files' => 'Files',
];

0 comments on commit 5081180

Please sign in to comment.