a0c3194e88
- Actualiza graph.facebook.com de v19.0 a v25.0 - Cambia parámetros posicionales a nombrados (parameter_name) en enviarTemplate para compatibilidad con plantillas avanzadas - enviarPromocion ahora pasa nombre fallback 'estudiante' y claves explícitas - imagenUrl() soporta imágenes con URL absoluta (http/https) además de rutas relativas de storage - Agrega Log::info del payload completo antes del envío para facilitar debugging Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1013 B
PHP
46 lines
1013 B
PHP
<?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
|
|
{
|
|
if (!$this->imagen) return null;
|
|
|
|
if (str_starts_with($this->imagen, 'http')) {
|
|
return $this->imagen;
|
|
}
|
|
|
|
return asset('storage/' . $this->imagen);
|
|
}
|
|
}
|