You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CreateBill.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Filament\Company\Resources\Purchases\BillResource\Pages;
  3. use App\Concerns\ManagesLineItems;
  4. use App\Concerns\RedirectToListPage;
  5. use App\Filament\Company\Resources\Purchases\BillResource;
  6. use App\Models\Accounting\Bill;
  7. use Filament\Resources\Pages\CreateRecord;
  8. use Filament\Support\Enums\MaxWidth;
  9. use Illuminate\Database\Eloquent\Model;
  10. class CreateBill extends CreateRecord
  11. {
  12. use ManagesLineItems;
  13. use RedirectToListPage;
  14. protected static string $resource = BillResource::class;
  15. public function getMaxContentWidth(): MaxWidth | string | null
  16. {
  17. return MaxWidth::Full;
  18. }
  19. protected function handleRecordCreation(array $data): Model
  20. {
  21. /** @var Bill $record */
  22. $record = parent::handleRecordCreation($data);
  23. $this->handleLineItems($record, collect($data['lineItems'] ?? []));
  24. $totals = $this->updateDocumentTotals($record, $data);
  25. $record->updateQuietly($totals);
  26. if (! $record->initialTransaction) {
  27. $record->createInitialTransaction();
  28. }
  29. return $record;
  30. }
  31. }