'datetime']; public static function crear(int $userId, int $monto, string $canal, ?string $nombreRemitente = null): static { static::where('user_id', $userId) ->where('estado', 'pendiente') ->update(['estado' => 'expirada']); return static::create([ 'user_id' => $userId, 'monto' => $monto, 'canal' => $canal, 'estado' => 'pendiente', 'nombre_remitente' => $nombreRemitente, ]); } public static function pendiente(int $userId): ?static { return static::where('user_id', $userId) ->where('estado', 'pendiente') ->where('created_at', '>=', now()->startOfDay()) ->latest('id') ->first(); } public static function nombresPrevios(int $userId): array { return static::where('user_id', $userId) ->where('estado', 'confirmada') ->whereNotNull('nombre_remitente') ->orderByDesc('id') ->limit(10) ->pluck('nombre_remitente') ->unique() ->values() ->toArray(); } public function confirmar(): void { $this->update(['estado' => 'confirmada']); } public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class); } }