Fix: socket permissions para nginx
This commit is contained in:
@@ -5,11 +5,17 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Alumno extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'opt_out' => 'boolean',
|
||||
'opt_out_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function existe($plantelId): bool
|
||||
{
|
||||
return $this->plantelUsuarios()
|
||||
@@ -52,4 +58,21 @@ class Alumno extends Model
|
||||
return $this->hasMany(Documento::class);
|
||||
}
|
||||
|
||||
public function promociones(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Promocion::class, 'alumno_promocion')
|
||||
->withPivot(['enviado_at', 'status_envio', 'whatsapp_mensaje_id']);
|
||||
}
|
||||
|
||||
public function whatsappLogs(): HasMany
|
||||
{
|
||||
return $this->hasMany(WhatsappLog::class);
|
||||
}
|
||||
|
||||
public function telefonoWhatsapp(): ?string
|
||||
{
|
||||
$user = $this->alumnos()->first();
|
||||
return $user?->telefono;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Promocion extends Model
|
||||
{
|
||||
protected $table = 'promociones';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'fecha_inicio' => 'date',
|
||||
'fecha_fin' => 'date',
|
||||
];
|
||||
|
||||
public function planteles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plantel::class, 'plantel_promocion');
|
||||
}
|
||||
|
||||
public function alumnos(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Alumno::class, 'alumno_promocion')
|
||||
->withPivot(['enviado_at', 'status_envio', 'whatsapp_mensaje_id']);
|
||||
}
|
||||
|
||||
public function isActiva(): bool
|
||||
{
|
||||
return $this->status === 'activo';
|
||||
}
|
||||
|
||||
public function imagenUrl(): ?string
|
||||
{
|
||||
return $this->imagen ? asset('storage/' . $this->imagen) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class WhatsappLog extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'payload' => 'array',
|
||||
'leido' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function alumno(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Alumno::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user