<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * @property integer $questionnaire_table_id
 * @property integer $created_by
 * @property int $table_no
 * @property string $table_title
 * @property string $table_html
 * @property string $table_js
 * @property string $created
 * @property string $modified
 * @property integer $status
 * @property User $user
 * @property ControlFigure[] $controlFigures
 * @property Questionnaire[] $questionnaires
 * @property SubQuestionnaire[] $subQuestionnaires
 */
class QuestionnaireTable extends Model
{
    /**
     * The table associated with the model.
     * 
     * @var string
     */
    protected $table = 'questionnaire_table';

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

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

    public $timestamps = false;

    /**
     * @var array
     */
    protected $fillable = ['created_by', 'questionnaire_id', 'table_no',
     'table_title', 'table_html', 'table_js', '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 questionnaire()
    {
        return $this->belongsTo('App\Models\Questionnaire', 'questionnaire_id',
         'questionnaire_id');
    }

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


    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function controlFigures()
    {
        return $this->hasMany('App\Models\ControlFigure', null,
         'questionnaire_table_id');
    }

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

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function subQuestionnaires()
    {
        return $this->hasMany('App\Models\SubQuestionnaire', null,
         'questionnaire_table_id');
    }
}
