MaterialCategory.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * MaterialCategory.php
  4. * 素材分类模型
  5. * Created on 2025/1/11 上午9:44
  6. * @author: hankaige
  7. */
  8. namespace app\models\material;
  9. use yii\behaviors\TimestampBehavior;
  10. /**
  11. * This is the model class for table "{{%material_category}}".
  12. * @property integer $id
  13. * @property integer $store_id
  14. * @property string $name
  15. * @property integer $sort 升序
  16. * @property integer $status
  17. */
  18. class MaterialCategory extends \yii\db\ActiveRecord
  19. {
  20. const STATUS_ACTIVE = 1;
  21. const STATUS_DELETE = 0;
  22. public static function tableName():string
  23. {
  24. return '{{%material_category}}';
  25. }
  26. public function behaviors():array
  27. {
  28. return [
  29. [
  30. // 自动更新创建和更新时间
  31. 'class' => TimestampBehavior::class,
  32. 'createdAtAttribute' => 'create_time',
  33. 'updatedAtAttribute' => 'update_time',
  34. 'value' => function(){
  35. return date('Y-m-d H:i:s');
  36. }
  37. ],
  38. ];
  39. }
  40. public function rules():array
  41. {
  42. return [
  43. [['store_id','sort','status'],'integer'],
  44. ['name','string'],
  45. [['store_id','name'],'required']
  46. ];
  47. }
  48. public function attributeLabels():array
  49. {
  50. return [
  51. 'store_id' => '商城ID',
  52. 'name' => '分类名称',
  53. 'sort' => '排序',
  54. 'status' => '状态'
  55. ];
  56. }
  57. }