GalleryItem.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\models\base;
  3. use Yii;
  4. /**
  5. * This is the model class for table "gallery_item".
  6. *
  7. * @property int $id
  8. * @property string|null $name
  9. * @property string|null $description
  10. * @property string|null $created_at
  11. * @property int|null $gallery_id
  12. * @property string|null $path
  13. * @property string|null $ext
  14. *
  15. * @property Gallery $gallery
  16. */
  17. class GalleryItem extends \yii\db\ActiveRecord
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return 'gallery_item';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['created_at'], 'safe'],
  33. [['gallery_id'], 'integer'],
  34. [['name', 'description', 'path', 'ext'], 'string', 'max' => 255],
  35. [['gallery_id'], 'exist', 'skipOnError' => true, 'targetClass' => Gallery::class, 'targetAttribute' => ['gallery_id' => 'id']],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'name' => 'Name',
  46. 'description' => 'Description',
  47. 'created_at' => 'Created At',
  48. 'gallery_id' => 'Gallery ID',
  49. 'path' => 'Path',
  50. 'ext' => 'Ext',
  51. ];
  52. }
  53. /**
  54. * Gets query for [[Gallery]].
  55. *
  56. * @return \yii\db\ActiveQuery
  57. */
  58. public function getGallery()
  59. {
  60. return $this->hasOne(Gallery::class, ['id' => 'gallery_id']);
  61. }
  62. }