<?php

namespace App\Models\Invite;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Invite\QuestionTagModel
 *
 * @property int $id
 * @property string|null $type 类型
 * @property string $tag
 * @property int $use
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 * @property int $hide
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Invite\QuestionTemplateModel[] $questions
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel display($bool)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel whereHide($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel whereTag($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel whereUse($value)
 * @mixin \Eloquent
 */
class QuestionTagModel extends Model
{
    //
    protected $table = 'kdgx_fpdx_invitation_question_template_tags';

    public $dateFormat = 'U';

    protected $fillable = ['tag', 'use', 'type', 'hide'];


    public function questions()
    {
        return $this->hasMany(QuestionTemplateModel::class, 'tag_id', 'id');
    }


    /**
     * 显示的
     * @param \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTagModel $query
     * @return mixed
     */
    public function scopeDisplay($query, bool $bool)
    {
        $hide = $bool ? 0 : 1;
        return $query->where('hide', $hide);
    }
}
