59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Restaurant\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\Authentication\Models\User;
|
|
|
|
class Purchase extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'restaurant_id',
|
|
'supplier_id',
|
|
'invoice_no',
|
|
'purchase_date',
|
|
'sub_total',
|
|
'discount_amount',
|
|
'tax_amount',
|
|
'total_amount',
|
|
'payment_status',
|
|
'payment_method',
|
|
'purchase_type',
|
|
'created_by',
|
|
'notes',
|
|
'status',
|
|
'created_at',
|
|
'updated_at',
|
|
'deleted_at',
|
|
];
|
|
|
|
public const TABLE_NAME = 'purchases';
|
|
|
|
protected $table = self::TABLE_NAME;
|
|
|
|
protected $casts = [
|
|
'purchase_date' => 'date:Y-m-d',
|
|
];
|
|
|
|
// 🔗 Relationships
|
|
public function items(): HasMany
|
|
{
|
|
return $this->hasMany(PurchaseItem::class, 'purchase_id');
|
|
}
|
|
|
|
public function supplier(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Supplier::class, 'supplier_id');
|
|
}
|
|
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
}
|