<?php

namespace App\Observers;

use App\Models\AmcContract;
use App\Notifications\DataChangeEmailNotification;
use Illuminate\Support\Facades\Notification;

class AmcContractActionObserver
{
    public function updated(AmcContract $model)
    {
        $data  = ['action' => 'updated', 'model_name' => 'AmcContract'];
        $users = \App\Models\User::whereHas('roles', function ($q) {
            return $q->where('title', 'Admin');
        })->get();
        Notification::send($users, new DataChangeEmailNotification($data));
    }
}
