96 lines
2.0 KiB
PHP
Executable File
96 lines
2.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'cedula',
|
|
'estado',
|
|
'img_perfil',
|
|
'rol_id',
|
|
'subvendedor_id',
|
|
'subvendedor',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
];
|
|
|
|
public function rol()
|
|
{
|
|
return $this->belongsTo(Role::class);
|
|
}
|
|
|
|
public function saldo()
|
|
{
|
|
return $this->hasOne(Saldo::class, 'usuario_id');
|
|
}
|
|
|
|
public function modificaciones()
|
|
{
|
|
return $this->hasOne(Configuracione::class, 'usermodifico_id');
|
|
}
|
|
|
|
public function permisos()
|
|
{
|
|
return $this->hasMany(Permiso::class, 'usuario_id');
|
|
}
|
|
|
|
public function preferenciales()
|
|
{
|
|
return $this->hasMany(Preferencial::class, 'usuario_id');
|
|
}
|
|
|
|
public function historiales_venta()
|
|
{
|
|
return $this->hasMany(Historiale::class, 'vendedor_id');
|
|
}
|
|
|
|
public function historiales_compra()
|
|
{
|
|
return $this->hasMany(Historiale::class, 'cliente_id');
|
|
}
|
|
|
|
public function recargas()
|
|
{
|
|
return $this->hasMany(recarga::class, 'usuario_id');
|
|
}
|
|
|
|
public function usuario_tarifas()
|
|
{
|
|
return $this->hasMany(Usuario_tarifa::class, 'usuario_id');
|
|
}
|
|
|
|
public function usuario_promos()
|
|
{
|
|
return $this->hasMany(Usuario_promo::class, 'usuario_id');
|
|
}
|
|
|
|
public function countActiveTarifas()
|
|
{
|
|
return $this->usuario_tarifas()->where('visible', 'true')->count();
|
|
}
|
|
|
|
public function countActivePromos()
|
|
{
|
|
return $this->usuario_promos()->where('visible', 'true')->count();
|
|
}
|
|
}
|