Files
Toiminnanohjaus/app/Modules/Billing/Infrastructure/Persistence/Eloquent/BillingExportModel.php
T
petriandClaude Sonnet 5.5 7d7b72989d Add an editable menu name and reserve billing material numbers on creation
- Company details get an optional "Valikon nimi", shown at the left of the
  main menu; it falls back to the application name when empty.
- A billing material gets its running number (billing_exports.number) only
  when it is created, so discarded drafts leave no gaps. Drafts have no
  number; existing created materials are numbered by the migration, and the
  CSV file name uses the number.
- TaskAssigneeMigrationTest rolls back from its own migration onward instead
  of assuming it is the last one.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-24 19:41:57 +02:00

50 lines
1.4 KiB
PHP

<?php
namespace App\Modules\Billing\Infrastructure\Persistence\Eloquent;
use App\Modules\Billing\Domain\Enums\ExportStatus;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Carbon;
/**
* Persistence model, used only inside the Billing Infrastructure layer.
*
* @property int $id
* @property int|null $number
* @property ExportStatus $status
* @property string|null $period Y-m
* @property int $created_by
* @property int|null $finalized_by
* @property Carbon|null $finalized_at
* @property Carbon $created_at
*/
#[Table('billing_exports')]
#[Fillable(['number', 'status', 'period', 'created_by', 'finalized_by', 'finalized_at'])]
class BillingExportModel extends Model
{
/**
* @return HasMany<BillingInvoiceModel, $this>
*/
public function invoices(): HasMany
{
return $this->hasMany(BillingInvoiceModel::class, 'billing_export_id')->orderBy('sort_order')->orderBy('id');
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'status' => ExportStatus::class,
'number' => 'integer',
'created_by' => 'integer',
'finalized_by' => 'integer',
'finalized_at' => 'datetime',
];
}
}