<?php

namespace App\Notifications;

use App\Models\OperationRun;
use App\Models\Tenant;
use App\Support\OpsUx\OperationUxPresenter;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class OperationRunCompleted extends Notification
{
    use Queueable;

    public function __construct(
        public OperationRun $run
    ) {}

    public function via(object $notifiable): array
    {
        return ['database'];
    }

    public function toDatabase(object $notifiable): array
    {
        $tenant = $this->run->tenant;

        return OperationUxPresenter::terminalDatabaseNotification(
            run: $this->run,
            tenant: $tenant instanceof Tenant ? $tenant : null,
        )
            ->getDatabaseMessage();
    }
}
