<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;

class WorkflowStepNotification extends Notification implements ShouldQueue
{
    use Queueable;

    protected $workflow;
    protected $step;
    protected $action;
    protected $by;

    public function __construct($workflow, $step, $action, $by)
    {
        $this->workflow = $workflow;
        $this->step = $step;
        $this->action = $action;
        $this->by = $by;
    }

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

    public function toDatabase($notifiable)
    {
        return [
            'title' => 'Workflow Step ' . ucfirst($this->action),
            'body' => $this->by . ' ' . $this->action . ' step "' . $this->step->name . '" in workflow "' . $this->workflow->name . '".',
            'workflow_id' => $this->workflow->id,
            'step_id' => $this->step->id,
            'action' => $this->action,
            'by' => $this->by,
        ];
    }
}
