<?php

namespace App;

use App\Http\Controllers\NotificationsController;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use App\Eventlog;

use App\User;




class Notifications extends Model
{
    //
    protected $table ='notifications';
    protected $fillable = array();

    public $timestamps = true;

    public function eventlog(){

        return $this->hasOne('App\Eventlog','id','eventlogs_id');

    }
    public static function getNotRead(){
        $notification = Notifications::where('user_to', '=', Auth::user()->id)
            ->where('is_read','=',0)
            ->where('is_archived','=',0)
            ->orderByDesc('id')->count();

        return $notification;


    }

    public function user(){

        return $this->hasOne('App\User','id','user_to');

    }

}

