<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * @property integer $sub_category_id
 * @property integer $category_id
 * @property integer $created_by
 * @property string $sub_category_name
 * @property string $description
 * @property string $created
 * @property string $modified
 * @property integer $status
 * @property User $user
 * @property Category $category
 * @property Institution[] $institutions
 * @property Questionnaire[] $questionnaires
 */
class SubCategory extends Model
{
    /**
     * The table associated with the model.
     * 
     * @var string
     */
    protected $table = 'sub_category';

    /**
     * The primary key for the model.
     * 
     * @var string
     */
    protected $primaryKey = 'sub_category_id';

    /**
     * The "type" of the auto-incrementing ID.
     * 
     * @var string
     */
    protected $keyType = 'integer';

    public $timestamps = false;

    /**
     * @var array
     */
    protected $fillable = ['category_id', 'created_by', 'sub_category_name', 'description', 'created', 'modified', 'status'];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo('App\Models\User', 'created_by', 'user_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function category()
    {
        return $this->belongsTo('App\Models\Category', 'category_id', 'category_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function institutions()
    {
        return $this->hasMany('App\Models\Institution', 'sub_category_id', 'sub_category_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function questionnaires()
    {
        return $this->hasMany('App\Models\Questionnaire', 'sub_category_id', 'sub_category_id');
    }
}
