<?php

namespace App\Models;

use App\Notifications\StripeErrorOccurred;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Notification;

class StripeError extends Model
{
    use HasFactory;

    protected $guarded = [];
    public static function boot()
    {
        parent::boot();

        self::created(function($model){
            Notification::send(User::permission('control wallet')->get(),new StripeErrorOccurred($model));
//            Engineer::where('email','muhammedkamal022@gmail.com')->first?->notifiy(new StripeErrorOccurred($model));
        });
    }

    public function user(){
        return $this->belongsTo(User::class)->withTrashed();
    }
}
