Ahora si :)))))))))))))))))
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user