<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class Support_Reply extends BaseModel
{
    use HasFactory;
    protected $table = 'support_replies';
    protected $fillable = ['support_id','message','sender_id','attachment_path','is_read'];

    public function addSupportReply($inputData){

        $return_data = self::create($inputData);
        return $return_data;
    }
    public function user()
    {
        return $this->belongsTo('App\Models\User');
    }

    public function getSupportById($supportId)
    {
        return self::where(['support_id'=>$supportId])->get();
    }

    public function updateSupportReply($inputData)
    {
        return self::where([['sender_id', '!=',$inputData['sender_id']],'support_id'=> $inputData['support_id'], 'is_read' => 0])->update(['is_read' => 1]);
    }
}



