ReportTopic.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\models;
  3. use app\models\ReportPhoto;
  4. use Yii;
  5. /**
  6. * This is the model class for table "report_topic".
  7. *
  8. * @property int $id
  9. * @property int|null $parent_id
  10. * @property string $date
  11. * @property string|null $title
  12. * @property string $body
  13. * @property string $folder
  14. * @property int $sort
  15. * @property int $active
  16. */
  17. class ReportTopic extends \yii\db\ActiveRecord
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return 'report_topic';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['parent_id', 'sort', 'active'], 'integer'],
  33. [['date'], 'safe'],
  34. [['title', 'body'], 'string'],
  35. [['body'], 'required'],
  36. [['folder'], 'string', 'max' => 250],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'parent_id' => 'Parent ID',
  47. 'date' => 'Date',
  48. 'title' => 'Title',
  49. 'body' => 'Body',
  50. 'folder' => 'Folder',
  51. 'sort' => 'Sort',
  52. 'active' => 'Active',
  53. ];
  54. }
  55. public function getUrl(){
  56. return "/photo/".$this->id;
  57. }
  58. public function getReport()
  59. {
  60. return $this->hasMany(ReportPhoto::className(), ['topic_id' => 'id'])->all();
  61. }
  62. }