init project

This commit is contained in:
2026-05-25 11:08:52 +07:00
parent a388c619b5
commit 895fdd9b83
1437 changed files with 384844 additions and 27 deletions

57
app/Models/Invoice.php Normal file
View File

@@ -0,0 +1,57 @@
<?php
namespace App\Models;
use App\Enums\RecordStatusEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Invoice extends BaseModel
{
public $timestamps = false;
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'invoices';
protected $fillable = ['invoice_code', 'sample_id', 'total', 'discount','discount_type', 'gross_total', 'deposit', 'bank_deposit', 'balance',
'pay_type', 'invoice_date', 'invoice_note', 'bank_name', 'transaction_ref', 'lab_id', 'is_hide_discount', 'first_paid_date','exchange_rate', BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD,
BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD
];
protected $hidden = [BaseModel::CREATED_AT_FIELD, BaseModel::CREATED_BY_FIELD, BaseModel::UPDATED_AT_FIELD, BaseModel::UPDATED_BY_FIELD, BaseModel::RECORD_STATUS_FIELD];
public static function boot()
{
parent::boot();
}
public function lab(){
return $this->belongsTo(Laboratory::class, 'lab_id','id');
}
public function sample(){
return $this->belongsTo(Sample::class, 'sample_id','id');
}
public function invoiceDetail(){
return $this->hasMany(InvoiceDetail::class, 'invoice_id', 'id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
}
public function repayments(){
return $this->hasMany(Repayment::class, 'invoice_id', 'id')->where(BaseModel::RECORD_STATUS_FIELD, RecordStatusEnum::ACTIVE);
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function modifier()
{
return $this->belongsTo(User::class, 'updated_by');
}
}