Просмотр файла app/Models/UserField.php

Размер файла: 1.32Kb
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Models;
  6.  
  7. use Illuminate\Database\Eloquent\Relations\HasMany;
  8. use Illuminate\Support\Collection;
  9.  
  10. /**
  11. * Class User
  12. *
  13. * @property int id
  14. * @property int sort
  15. * @property string type
  16. * @property string name
  17. * @property int min
  18. * @property int max
  19. * @property bool required
  20. *
  21. * @property Collection<UserData> data
  22. */
  23. class UserField extends BaseModel
  24. {
  25. /**
  26. * Type fields
  27. */
  28. public const INPUT = 'input';
  29. public const TEXTAREA = 'textarea';
  30.  
  31. /**
  32. * All types
  33. */
  34. public const TYPES = [
  35. self::INPUT,
  36. self::TEXTAREA,
  37. ];
  38.  
  39. /**
  40. * The attributes that should be cast to native types.
  41. *
  42. * @var string[]
  43. */
  44. protected $casts = [
  45. 'required' => 'bool',
  46. ];
  47.  
  48. /**
  49. * Indicates if the model should be timestamped.
  50. *
  51. * @var bool
  52. */
  53. public $timestamps = false;
  54.  
  55. /**
  56. * The attributes that are mass assignable.
  57. *
  58. * @var string[]
  59. */
  60. protected $fillable = [
  61. 'sort',
  62. 'type',
  63. 'name',
  64. 'min',
  65. 'max',
  66. 'required',
  67. ];
  68.  
  69. /**
  70. * Возвращает данные
  71. *
  72. * @return HasMany
  73. */
  74. public function data(): HasMany
  75. {
  76. return $this->hasMany(UserData::class, 'field_id');
  77. }
  78. }