41 lines
868 B
PHP
41 lines
868 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Notificacion extends Model
|
|
{
|
|
protected $table = 'notificaciones';
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = [
|
|
'tipo_destinatario',
|
|
'id_destinatario',
|
|
'tipo',
|
|
'titulo',
|
|
'mensaje',
|
|
'url_accion',
|
|
'leida',
|
|
'enviada_email',
|
|
'creada_en',
|
|
];
|
|
|
|
protected $casts = [
|
|
'leida' => 'boolean',
|
|
'enviada_email' => 'boolean',
|
|
'creada_en' => 'datetime',
|
|
];
|
|
|
|
// ── Scopes ──
|
|
public function scopeNoLeidas($query)
|
|
{
|
|
return $query->where('leida', false);
|
|
}
|
|
|
|
public function scopeParaUsuario($query, string $tipo, $id)
|
|
{
|
|
return $query->where('tipo_destinatario', $tipo)->where('id_destinatario', (string)$id);
|
|
}
|
|
}
|