feat(client): add client context to sales and expenses creation

- Disable branch selection in sale form when creating from client context
- Pass client ID to create pages via URL parameter
- Update breadcrumbs to reflect client navigation path
- Simplify relation managers by reusing resource tables and adding custom create actions
This commit is contained in:
Jp
2026-02-15 17:43:33 +08:00
parent ff07f6f810
commit fbc01bf1a4
5 changed files with 87 additions and 57 deletions

View File

@@ -24,31 +24,13 @@ class ExpensesRelationManager extends RelationManager
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('supplier')
->columns([
TextColumn::make('supplier'),
TextColumn::make('reference_number'),
TextColumn::make('voucher_number'),
TextColumn::make('branch.code'),
TextColumn::make('happened_on'),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make()
->url(fn () => ExpenseResource::getUrl('create', ['client_id' => $this->getOwnerRecord()->id])),
])
->actions([
Tables\Actions\EditAction::make()
->url(fn (Expense $record) => ExpenseResource::getUrl('edit', ['record' => $record])),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
return ExpenseResource::table($table)->headerActions([
Tables\Actions\Action::make('New Expense')->action('openCreateForm'),
]);
}
public function openCreateForm()
{
return redirect()->route('filament.admin.resources.expenses.create', ['client_id' => $this->getOwnerRecord()->id]);
}
}