<?php

namespace App\Models;

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

class VerificationRequest extends Model
{
    use HasFactory;
    public static function boot()
    {
        parent::boot();

        self::created(function($model){
            Notification::send(User::permission('control contents')->get(),new VerificationRequestCreated($model));
        });

    }
    public function entity(){
        return $this->morphTo();
    }

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