This commit is contained in:
Juan Felipe Duarte
2025-06-14 09:03:54 -07:00
parent 14d6665253
commit 6789ce3fb3
5 changed files with 64 additions and 30 deletions
+2 -1
View File
@@ -8,9 +8,10 @@ use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
use HasFactory;
protected $fillable = [
'nombre',
'subvendedor_id',
];
public function usuarios(){
+14 -25
View File
@@ -12,11 +12,6 @@ class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
@@ -24,24 +19,16 @@ class User extends Authenticatable
'cedula',
'estado',
'img_perfil',
'rol_id'
'rol_id',
'subvendedor_id',
'subvendedor',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
@@ -51,46 +38,47 @@ class User extends Authenticatable
return $this->belongsTo(Role::class);
}
public function saldo()
public function saldo()
{
return $this->hasOne(Saldo::class, 'usuario_id');
}
public function modificaciones()
public function modificaciones()
{
return $this->hasOne(Configuracione::class, 'usermodifico_id');
}
public function permisos()
public function permisos()
{
return $this->hasMany(Permiso::class, 'usuario_id');
}
public function preferenciales()
public function preferenciales()
{
return $this->hasMany(Preferencial::class, 'usuario_id');
}
public function historiales_venta()
public function historiales_venta()
{
return $this->hasMany(Historiale::class, 'vendedor_id');
}
public function historiales_compra()
public function historiales_compra()
{
return $this->hasMany(Historiale::class, 'cliente_id');
}
public function recargas()
public function recargas()
{
return $this->hasMany(recarga::class, 'usuario_id');
}
public function usuario_tarifas()
public function usuario_tarifas()
{
return $this->hasMany(Usuario_tarifa::class, 'usuario_id');
}
public function usuario_promos()
public function usuario_promos()
{
return $this->hasMany(Usuario_promo::class, 'usuario_id');
}
@@ -99,6 +87,7 @@ class User extends Authenticatable
{
return $this->usuario_tarifas()->where('visible', 'true')->count();
}
public function countActivePromos()
{
return $this->usuario_promos()->where('visible', 'true')->count();
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('subvendedor_id')->nullable()->after('visto');
$table->boolean('subvendedor')->default(true)->after('subvendedor_id');
});
}
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['subvendedor_id', 'subvendedor']);
});
}
};
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('roles', function (Blueprint $table) {
$table->string('subvendedor_id')->nullable()->after('nombre');
});
}
public function down()
{
Schema::table('roles', function (Blueprint $table) {
$table->dropColumn('subvendedor_id');
});
}
};
@@ -65,7 +65,7 @@
<x-slot name="tbody">
@foreach ($clientes as $cliente)
<tr class="table-row md:hidden border-gray-200 text-left" x-data="{ extraInfo: false, openOption: false, isOpen1: false, isOpen2: false }">
<td @click="extraInfo = true">{{ $cliente->nombre_cliente ?? $cliente->cliente->name }}</td>
<td @click="extraInfo = true">{{ $cliente->nombre_cliente ?? $cliente->cliente->name ?? '' }}</td>
<td @click="extraInfo = true" class="relative">
@if (!empty($cliente->cuentas_obsoletas->unique()))
@foreach ($cliente->cuentas_obsoletas->unique() as $cuenta)
@@ -331,15 +331,14 @@
</td>
<td @click="extraInfo = true">{{ $this->consultaPassword($cliente->id) }}</td>
<td @click="extraInfo = true">
<p
class="rounded-md font-medium text-center @if ($cliente->estado == 'activo') bg-green-500 text-white @endif @if ($cliente->estado == 'pendiente') bg-yellow-500 @endif">
<p class="rounded-md font-medium text-center @if ($cliente->estado == 'activo') bg-green-500 text-white @endif @if ($cliente->estado == 'pendiente') bg-yellow-500 @endif">
{{ $cliente->estado ?? '' }}
</p>
</td>
</tr>
<tr class="hidden md:table-row border-gray-200 text-left w-full" x-data="{ openOption: false, isOpen1: false, isOpen2: false }">
<td>{{ $cliente->nombre_cliente ?? $cliente->cliente->name }}</td>
<td>{{ $cliente->nombre_cliente ?? $cliente->cliente->name ?? '' }}</td>
<td>
@if (!empty($cliente->cuentas_obsoletas->unique()))