QuestionTemplateModel.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Models\Invite;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * App\Models\Invite\QuestionTemplateModel
  6. *
  7. * @property int $id
  8. * @property int $created_at
  9. * @property int $updated_at
  10. * @property string $type 类型
  11. * @property string $title 问题
  12. * @property string $question 问题
  13. * @property string $author 作者
  14. * @property int $tag_id 标签ID
  15. * @property int $choice_count 选择次数
  16. * @property int $select_count 精选次数
  17. * @property int $hide 隐藏
  18. * @property-read \App\Models\Invite\QuestionTagModel $tag
  19. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel display($bool)
  20. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel newModelQuery()
  21. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel newQuery()
  22. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel query()
  23. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereAuthor($value)
  24. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereChoiceCount($value)
  25. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereCreatedAt($value)
  26. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereHide($value)
  27. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereId($value)
  28. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereQuestion($value)
  29. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereSelectCount($value)
  30. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereTagId($value)
  31. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereTitle($value)
  32. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereType($value)
  33. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Invite\QuestionTemplateModel whereUpdatedAt($value)
  34. * @mixin \Eloquent
  35. */
  36. class QuestionTemplateModel extends Model
  37. {
  38. //
  39. protected $table = 'kdgx_fpdx_invitation_question_templates';
  40. protected $fillable = ['type', 'question', 'author', 'tag_id', 'choice_count', 'select_count', 'hide'];
  41. public $timestamps = false;
  42. public function tag()
  43. {
  44. return $this->belongsTo(QuestionTagModel::class, 'tag_id', 'id')->select('id', 'tag');
  45. }
  46. /**
  47. * 显示的
  48. * @param $query
  49. * @return mixed
  50. */
  51. public function scopeDisplay($query, bool $bool)
  52. {
  53. $hide = $bool ? 0 : 1;
  54. return $query->where('hide', $hide);
  55. }
  56. }