Files
GLOC/app/Models/Customer.php
2026-02-07 04:52:11 +07:00

42 lines
886 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use MongoDB\Laravel\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Customer extends Model
{
use HasFactory;
protected $fillable = [
'name',
'address',
'owner_name',
'phone',
'latitude',
'longitude',
'city',
'pic_sales_id',
'category', // Added for consistency with Merchant
'agent_id', // Added for ownership
];
/**
* Get the sales user associated with the customer.
*/
public function sales(): BelongsTo
{
return $this->belongsTo(User::class, 'pic_sales_id');
}
/**
* Get the agent associated with the customer.
*/
public function agent(): BelongsTo
{
return $this->belongsTo(Agent::class, 'agent_id');
}
}