<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * @property string $representative_id
 * @property string $patients_id
 * @property string $title
 * @property string $description
 * @property string $created_at
 * @property string $updated_at
 * @property Patient $patient
 * @property Representative $representative
 */
class RelationShip extends Model
{
    /**
     * The table associated with the model.
     * 
     * @var string
     */
    protected $table = 'relationship';

    /**
     * @var array
     */
    protected $fillable = ['representative_id','patients_id','title', 'description', 'created_at', 'updated_at'];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function patient()
    {
        return $this->belongsTo('App\Patient', 'patients_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function representative()
    {
        return $this->belongsTo('App\Representative');
    }

    /**
     * 
     */
    public static function factoryCreate($representativeId,$patientId,$data){
        $relationShip = [];
        $relationShip["representative_id"]  = $representativeId;
        $relationShip["patients_id"]        = $patientId;
        $relationShip["title"]              = $data["relationship"];
        $relationShip["description"]        = $data["relationship"];
        return $relationShip;
    }
}
