<?php

namespace App\Domain\Feeds\Observers;

use Illuminate\Support\Str;
use App\Domain\Feeds\Models\Feed;
use App\Events\FeedAddProcessed;
use App\Events\FeedRemoveProcessed;
use App\Events\FeedUpdateProcessed;

class FeedObserver
{
    public function creating(Feed $feed)
    {
        $uuid = (string) Str::uuid();
        $feed->slug = $uuid . '_' . $feed->type;
    }


    public function created(Feed $feed)
    {
        FeedAddProcessed::dispatch($feed);
    }

    public function deleted(Feed $feed)
    {
        FeedRemoveProcessed::dispatch($feed);
    }

    // public function forceDeleted(Feed $feed)
    // {
    //     dd('forceDeleted');
    // }

    public function updated(Feed $feed)
    {
        FeedUpdateProcessed::dispatch($feed);
    }

}
