<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MainNotification extends Model
{
    use HasFactory;

    protected $fillable = [
        'title', 
        'content',
        'generated_by',
        'image',
    ];

    public function getImageAttribute($icon){

        return get_uploaded_image_url( $icon, 'notification_image_upload_dir', 'camera_placeholder.png' );
        
    }

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

    public function notifications()
    {
        return $this->hasMany(Notification::class, 'main_notification_id');
    }
}
