diff --git a/app/Models/Role.php b/app/Models/Role.php index 32040da..80d4fea 100755 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -8,9 +8,10 @@ use Illuminate\Database\Eloquent\Model; class Role extends Model { use HasFactory; + protected $fillable = [ 'nombre', - + 'subvendedor_id', ]; public function usuarios(){ diff --git a/app/Models/User.php b/app/Models/User.php index 308442f..55efa96 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -12,11 +12,6 @@ class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; - /** - * The attributes that are mass assignable. - * - * @var array - */ 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 - */ protected $hidden = [ 'password', 'remember_token', ]; - /** - * The attributes that should be cast. - * - * @var array - */ 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(); diff --git a/database/migrations/2025_06_13_155300_add_subvendedor_fields_to_users_table.php b/database/migrations/2025_06_13_155300_add_subvendedor_fields_to_users_table.php new file mode 100644 index 0000000..4e41bf9 --- /dev/null +++ b/database/migrations/2025_06_13_155300_add_subvendedor_fields_to_users_table.php @@ -0,0 +1,23 @@ +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']); + }); + } +}; diff --git a/database/migrations/2025_06_13_155742_add_subvendedor_id_to_roles_table.php b/database/migrations/2025_06_13_155742_add_subvendedor_id_to_roles_table.php new file mode 100644 index 0000000..4185f5c --- /dev/null +++ b/database/migrations/2025_06_13_155742_add_subvendedor_id_to_roles_table.php @@ -0,0 +1,22 @@ +string('subvendedor_id')->nullable()->after('nombre'); + }); + } + + public function down() + { + Schema::table('roles', function (Blueprint $table) { + $table->dropColumn('subvendedor_id'); + }); + } +}; diff --git a/resources/views/livewire/show-clientes.blade.php b/resources/views/livewire/show-clientes.blade.php index d2ca9c9..5efb4ad 100755 --- a/resources/views/livewire/show-clientes.blade.php +++ b/resources/views/livewire/show-clientes.blade.php @@ -65,7 +65,7 @@ @foreach ($clientes as $cliente) - {{ $cliente->nombre_cliente ?? $cliente->cliente->name }} + {{ $cliente->nombre_cliente ?? $cliente->cliente->name ?? '' }} @if (!empty($cliente->cuentas_obsoletas->unique())) @foreach ($cliente->cuentas_obsoletas->unique() as $cuenta) @@ -331,15 +331,14 @@ {{ $this->consultaPassword($cliente->id) }} -

+

{{ $cliente->estado ?? '' }}

- {{ $cliente->nombre_cliente ?? $cliente->cliente->name }} + {{ $cliente->nombre_cliente ?? $cliente->cliente->name ?? '' }} @if (!empty($cliente->cuentas_obsoletas->unique()))