- 新增2个migration(11张表): finance(6表)/hr(5表) - 新增11个Model + 11个Controller - 新增50条API路由(总计262条) - 新增2个前端API模块 + 10个管理页面 - 迁移运行通过, vite build验证通过
42 lines
975 B
PHP
42 lines
975 B
PHP
<?php
|
|
|
|
namespace App\Models\Finance;
|
|
|
|
use App\Models\Crm\Customer;
|
|
use App\Models\User;
|
|
use App\Traits\BelongsToStore;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Invoice extends Model
|
|
{
|
|
use BelongsToStore;
|
|
|
|
protected $fillable = [
|
|
'store_id', 'invoice_no', 'customer_id', 'type', 'amount',
|
|
'tax_amount', 'title', 'tax_no', 'related_type', 'related_id',
|
|
'status', 'operator_id', 'issued_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'type' => 'integer',
|
|
'status' => 'integer',
|
|
'amount' => 'decimal:2',
|
|
'tax_amount' => 'decimal:2',
|
|
'issued_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function operator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'operator_id');
|
|
}
|
|
}
|