MaterialDownload.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace addons\Material\common\models;
  3. use Yii;
  4. use yii\db\Exception;
  5. /**
  6. * This is the model class for table "qimall_addons_material_download".
  7. * @property int $id
  8. * @property int $mall_id 商户ID
  9. * @property int $user_id 下载素材的用户id
  10. * @property int $material_id 素材id
  11. * @property int|null $created_at 创建时间
  12. * @property string|null $updated_at 更新时间
  13. */
  14. class MaterialDownload extends \common\models\base\BaseActiveRecord
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function tableName()
  20. {
  21. return 'qimall_addons_material_download';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['mall_id', 'user_id', 'material_id'], 'required'],
  30. [['mall_id', 'user_id', 'material_id', 'created_at'], 'integer'],
  31. [['updated_at'], 'safe'],
  32. ];
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'id' => 'ID',
  41. 'mall_id' => '商户ID',
  42. 'user_id' => '下载素材的用户id',
  43. 'material_id' => '素材id',
  44. 'created_at' => '创建时间',
  45. 'updated_at' => '更新时间',
  46. ];
  47. }
  48. /**
  49. * 保存数据
  50. * @Author: ltm
  51. * @DateTime: 2021/12/14 0022 17:13
  52. * @Copyright: copyright (c) 2021 广东七件事集团
  53. * @param array $params
  54. * @return AddonsMaterial|bool
  55. */
  56. public static function setData(array $params){
  57. try{
  58. $model = new self();
  59. $model->loadDefaultValues();
  60. $model->mall_id = $params['mall_id'];
  61. if(!$model->load($params,'') || !$model->save()){
  62. throw new Exception($model->getErrorMessage());
  63. }
  64. return $model;
  65. }catch(\Exception $e){
  66. self::$static_error = $e->getMessage();
  67. return false;
  68. }
  69. }
  70. }