juan.zapata af8749abcd WIP (#1)
Co-authored-by: Juan Felipe Zapata Moreno <zapata_pipe@hotmail.com>
Reviewed-on: #1
2025-11-10 22:45:59 +00:00

52 lines
1.1 KiB
PHP

<?php namespace App\Models;
/**
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
*/
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
/**
* Descripción
*
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
*
* @version 1.0.0
*/
class Client extends Model
{
protected $fillable = [
'name',
'paternal',
'maternal',
'email',
'phone',
'rfc',
];
public function sales()
{
return $this->hasMany(Sale::class);
}
public function clientSims()
{
return $this->hasMany(ClientSim::class);
}
public function simCards()
{
return $this->belongsToMany(SimCard::class, 'client_sims')
->withPivot('assigned_at', 'released_at', 'is_active')
->withTimestamps();
}
public function fullName(): Attribute
{
return Attribute::make(
get: fn () => $this->name . ' ' . $this->paternal . ' ' . $this->maternal,
);
}
}