2025-12-30 15:03:19 +08:00
|
|
|
<?php
|
|
|
|
|
|
2026-01-26 10:37:47 +08:00
|
|
|
namespace App\Modules\Procurement\Models;
|
2025-12-30 15:03:19 +08:00
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2026-01-26 10:37:47 +08:00
|
|
|
use Spatie\Activitylog\Traits\LogsActivity;
|
|
|
|
|
use Spatie\Activitylog\LogOptions;
|
|
|
|
|
use App\Modules\Inventory\Models\Product;
|
2025-12-30 15:03:19 +08:00
|
|
|
|
2026-01-26 10:37:47 +08:00
|
|
|
class Vendor extends Model
|
2025-12-30 15:03:19 +08:00
|
|
|
{
|
2026-01-26 10:37:47 +08:00
|
|
|
/** @use HasFactory<\Database\Factories\VendorFactory> */
|
|
|
|
|
use HasFactory, LogsActivity;
|
2025-12-30 15:03:19 +08:00
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'code',
|
|
|
|
|
'name',
|
2026-01-26 14:59:24 +08:00
|
|
|
'short_name',
|
|
|
|
|
'tax_id',
|
|
|
|
|
'owner',
|
|
|
|
|
'contact_name',
|
|
|
|
|
'tel',
|
2026-01-26 10:37:47 +08:00
|
|
|
'phone',
|
2026-01-26 14:59:24 +08:00
|
|
|
'email',
|
2025-12-30 15:03:19 +08:00
|
|
|
'address',
|
2026-01-26 14:59:24 +08:00
|
|
|
'remark',
|
2025-12-30 15:03:19 +08:00
|
|
|
];
|
|
|
|
|
|
2026-01-26 14:59:24 +08:00
|
|
|
|
2026-01-26 10:37:47 +08:00
|
|
|
|
|
|
|
|
public function purchaseOrders(): \Illuminate\Database\Eloquent\Relations\HasMany
|
2026-01-19 11:47:10 +08:00
|
|
|
{
|
2026-01-26 10:37:47 +08:00
|
|
|
return $this->hasMany(PurchaseOrder::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
|
|
|
{
|
|
|
|
|
return LogOptions::defaults()
|
2026-01-19 11:47:10 +08:00
|
|
|
->logAll()
|
|
|
|
|
->logOnlyDirty()
|
|
|
|
|
->dontSubmitEmptyLogs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function tapActivity(\Spatie\Activitylog\Contracts\Activity $activity, string $eventName)
|
|
|
|
|
{
|
|
|
|
|
$properties = $activity->properties;
|
2026-01-19 15:32:41 +08:00
|
|
|
|
|
|
|
|
$snapshot = $properties['snapshot'] ?? [];
|
|
|
|
|
$snapshot['name'] = $this->name;
|
|
|
|
|
$properties['snapshot'] = $snapshot;
|
2026-01-19 11:47:10 +08:00
|
|
|
|
|
|
|
|
$activity->properties = $properties;
|
|
|
|
|
}
|
2025-12-30 15:03:19 +08:00
|
|
|
}
|