<?php

namespace App\Models;

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

class Notification extends Model
{
    use HasFactory;

    public function from_user()
    {
        return $this->belongsTo('App\Models\User', 'from');
    }

    public static function new($arr)
    {

        $notification = new Notification();
        $notification->from = $arr['from'];
        $notification->user_id = $arr['user_id'];
        $notification->seen = $arr['seen'];
        $notification->message = $arr['message'];
        $notification->link = $arr['link'];
        $notification->name = $arr['name'];
        $notification->save();

    }
}
