@@ -161,8 +161,9 @@ |
||
161 | 161 | return ['url' => $attachment, 'path' => $attachment,]; |
162 | 162 | } else if (is_array($attachment)) { |
163 | 163 | return $attachment; |
164 | - } else if ($attachment instanceof Arrayable) |
|
165 | - return $attachment->toArray(); |
|
164 | + } else if ($attachment instanceof Arrayable) { |
|
165 | + return $attachment->toArray(); |
|
166 | + } |
|
166 | 167 | return []; |
167 | 168 | } |
168 | 169 |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | if (empty($this->url)) { |
96 | 96 | if ($this->onlyImage === false) { |
97 | 97 | $this->url = $this->multiple ? ['/upload/files-upload'] : ['/upload/file-upload']; |
98 | - $fileAllowFiles = Yii::$app->getSettings()->get('fileAllowFiles','attachment'); |
|
98 | + $fileAllowFiles = Yii::$app->getSettings()->get('fileAllowFiles', 'attachment'); |
|
99 | 99 | $regExp = '/(\.|\/)('; |
100 | 100 | $extensions = explode(',', $fileAllowFiles); |
101 | 101 | foreach ($extensions as $extension) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | $this->fileInputName = md5($this->name); |
132 | 132 | if (!array_key_exists('file_param', $this->url)) { |
133 | - $this->url['file_param'] = $this->fileInputName;//服务器需要通过这个判断是哪一个input name上传的 |
|
133 | + $this->url['file_param'] = $this->fileInputName; //服务器需要通过这个判断是哪一个input name上传的 |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | $this->clientOptions = ArrayHelper::merge($this->clientOptions, [ |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | protected function formatAttachment($attachment) |
161 | 161 | { |
162 | 162 | if (!empty($attachment) && is_string($attachment)) { |
163 | - return ['url' => $attachment, 'path' => $attachment,]; |
|
163 | + return ['url' => $attachment, 'path' => $attachment, ]; |
|
164 | 164 | } else if (is_array($attachment)) { |
165 | 165 | return $attachment; |
166 | 166 | } else if ($attachment instanceof Arrayable) |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public static function getImageMaxSizeByte() |
48 | 48 | { |
49 | - $imageMaxSize = Yii::$app->getSettings()->get('imageMaxSize','attachment'); |
|
49 | + $imageMaxSize = Yii::$app->getSettings()->get('imageMaxSize', 'attachment'); |
|
50 | 50 | return self::getMaxUploadByte($imageMaxSize); |
51 | 51 | } |
52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public static function getVideoMaxSizeByte() |
58 | 58 | { |
59 | - $videoMaxSize = Yii::$app->getSettings()->get('videoMaxSize','attachment'); |
|
59 | + $videoMaxSize = Yii::$app->getSettings()->get('videoMaxSize', 'attachment'); |
|
60 | 60 | return self::getMaxUploadByte($videoMaxSize); |
61 | 61 | } |
62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function getFileMaxSizeByte() |
68 | 68 | { |
69 | - $fileMaxSize = Yii::$app->getSettings()->get('fileMaxSize','attachment'); |
|
69 | + $fileMaxSize = Yii::$app->getSettings()->get('fileMaxSize', 'attachment'); |
|
70 | 70 | return self::getMaxUploadByte($fileMaxSize); |
71 | 71 | } |
72 | 72 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public static function getAcceptImageMimeTypes() |
78 | 78 | { |
79 | - $imageAllowFiles = Yii::$app->getSettings()->get('imageAllowFiles','attachment'); |
|
79 | + $imageAllowFiles = Yii::$app->getSettings()->get('imageAllowFiles', 'attachment'); |
|
80 | 80 | $extensions = explode(',', $imageAllowFiles); |
81 | - array_walk($extensions, function (&$value) { |
|
81 | + array_walk($extensions, function(&$value) { |
|
82 | 82 | $value = 'image/' . $value; |
83 | 83 | }); |
84 | 84 | return $extensions; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public static function normalizeExtension($extensions) |
94 | 94 | { |
95 | 95 | $extensions = explode(',', $extensions); |
96 | - array_walk($extensions, function (&$value) { |
|
96 | + array_walk($extensions, function(&$value) { |
|
97 | 97 | $value = '.' . $value; |
98 | 98 | }); |
99 | 99 | return $extensions; |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | const AFTER_REGISTER = 'afterRegister'; |
49 | 49 | |
50 | 50 | //场景定义 |
51 | - const SCENARIO_CREATE = 'create';//后台或控制台创建用户 |
|
52 | - const SCENARIO_UPDATE = 'update';//后台或控制台修改用户 |
|
53 | - const SCENARIO_REGISTER = 'basic_create';//邮箱注册 |
|
54 | - const SCENARIO_EMAIL_REGISTER = 'email_create';//邮箱注册 |
|
55 | - const SCENARIO_MOBILE_REGISTER = 'mobile_create';//手机号注册 |
|
56 | - const SCENARIO_SETTINGS = 'settings';//更新 |
|
57 | - const SCENARIO_CONNECT = 'connect';//账户链接或自动注册新用户 |
|
51 | + const SCENARIO_CREATE = 'create'; //后台或控制台创建用户 |
|
52 | + const SCENARIO_UPDATE = 'update'; //后台或控制台修改用户 |
|
53 | + const SCENARIO_REGISTER = 'basic_create'; //邮箱注册 |
|
54 | + const SCENARIO_EMAIL_REGISTER = 'email_create'; //邮箱注册 |
|
55 | + const SCENARIO_MOBILE_REGISTER = 'mobile_create'; //手机号注册 |
|
56 | + const SCENARIO_SETTINGS = 'settings'; //更新 |
|
57 | + const SCENARIO_CONNECT = 'connect'; //账户链接或自动注册新用户 |
|
58 | 58 | const SCENARIO_PASSWORD = 'password'; |
59 | 59 | |
60 | 60 | /** |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | static::SCENARIO_EMAIL_REGISTER => ['nickname', 'email', 'password'], |
96 | 96 | static::SCENARIO_MOBILE_REGISTER => ['mobile', 'password'], |
97 | 97 | static::SCENARIO_SETTINGS => ['username', 'email', 'password'], |
98 | - static::SCENARIO_CONNECT => ['nickname', 'email', 'password'],//链接账户密码可以为空邮箱可以为空 |
|
99 | - static::SCENARIO_PASSWORD => ['password'],//只修改密码 |
|
98 | + static::SCENARIO_CONNECT => ['nickname', 'email', 'password'], //链接账户密码可以为空邮箱可以为空 |
|
99 | + static::SCENARIO_PASSWORD => ['password'], //只修改密码 |
|
100 | 100 | ]); |
101 | 101 | } |
102 | 102 |
@@ -64,7 +64,7 @@ |
||
64 | 64 | public function rules() |
65 | 65 | { |
66 | 66 | return [ |
67 | - [[ 'model_id'], 'required'], |
|
67 | + [['model_id'], 'required'], |
|
68 | 68 | [['user_id', 'model_id'], 'integer'], |
69 | 69 | [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']], |
70 | 70 | ]; |
@@ -72,7 +72,7 @@ |
||
72 | 72 | 'attributes' => [ |
73 | 73 | ActiveRecord::EVENT_BEFORE_INSERT => 'user_id' |
74 | 74 | ], |
75 | - 'value' => function () { |
|
75 | + 'value' => function() { |
|
76 | 76 | return Yii::$app->user->id; |
77 | 77 | } |
78 | 78 | ], |
@@ -3,7 +3,7 @@ |
||
3 | 3 | $config = [ |
4 | 4 | 'components' => [ |
5 | 5 | 'cache' => [ |
6 | - 'keyPrefix' => 'rest', //前缀 |
|
6 | + 'keyPrefix' => 'rest', //前缀 |
|
7 | 7 | ], |
8 | 8 | 'request' => [ |
9 | 9 | 'class' => yuncms\console\Request::class, |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | use Yii; |
22 | 22 | use <?= $generator->baseClass?>; |
23 | 23 | use yii\db\Connection; |
24 | -<?php if(isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
24 | +<?php if (isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
25 | 25 | use yii\helpers\Inflector; |
26 | 26 | <?php endif; ?> |
27 | 27 | |
28 | 28 | use yii\caching\DbDependency; |
29 | 29 | use yii\caching\ChainedDependency; |
30 | -<?php if(isset($labels['created_at'])): ?> |
|
30 | +<?php if (isset($labels['created_at'])): ?> |
|
31 | 31 | use yii\behaviors\TimestampBehavior; |
32 | 32 | <?php endif; ?> |
33 | -<?php if(isset($labels['user_id'])): ?> |
|
33 | +<?php if (isset($labels['user_id'])): ?> |
|
34 | 34 | use yii\behaviors\BlameableBehavior; |
35 | 35 | <?php endif; ?> |
36 | -<?php if(isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
36 | +<?php if (isset($labels['slug']) || isset($labels['uuid'])): ?> |
|
37 | 37 | use yii\behaviors\AttributeBehavior; |
38 | 38 | <?php endif; ?> |
39 | 39 | use yuncms\helpers\DateHelper; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | <?php endif; ?> |
54 | 54 | * |
55 | 55 | * @property-read boolean $isAuthor 是否是作者 |
56 | -<?php if(isset($labels['status'])): ?> |
|
56 | +<?php if (isset($labels['status'])): ?> |
|
57 | 57 | * @property-read boolean $isDraft 是否草稿 |
58 | 58 | * @property-read boolean $isPublished 是否发布 |
59 | 59 | <?php endif; ?> |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | //场景定义 |
65 | 65 | const SCENARIO_CREATE = 'create';//创建 |
66 | 66 | const SCENARIO_UPDATE = 'update';//更新 |
67 | -<?php if(isset($labels['status'])): ?> |
|
67 | +<?php if (isset($labels['status'])): ?> |
|
68 | 68 | //状态定义 |
69 | 69 | const STATUS_DRAFT = 0b0;//草稿 |
70 | 70 | const STATUS_REVIEW = 0b1;//待审核 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $behaviors['timestamp'] = [ |
98 | 98 | 'class' => TimestampBehavior::className() |
99 | 99 | ]; |
100 | -<?php elseif(isset($labels['created_at'])): ?> |
|
100 | +<?php elseif (isset($labels['created_at'])): ?> |
|
101 | 101 | $behaviors['timestamp'] = [ |
102 | 102 | 'class' => TimestampBehavior::className(), |
103 | 103 | 'attributes' => [ |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ], |
106 | 106 | ]; |
107 | 107 | <?php endif; ?> |
108 | -<?php if(isset($labels['user_id'])): ?> |
|
108 | +<?php if (isset($labels['user_id'])): ?> |
|
109 | 109 | $behaviors['user'] = [ |
110 | 110 | 'class' => BlameableBehavior::className(), |
111 | 111 | 'attributes' => [ |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ], |
114 | 114 | ]; |
115 | 115 | <?php endif; ?> |
116 | -<?php if(isset($labels['slug'])): ?> |
|
116 | +<?php if (isset($labels['slug'])): ?> |
|
117 | 117 | $behaviors['slug'] = [ |
118 | 118 | 'class' => AttributeBehavior::className(), |
119 | 119 | 'attributes' => [ |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | ]; |
126 | 126 | <?php endif; ?> |
127 | -<?php if(isset($labels['uuid'])): ?> |
|
127 | +<?php if (isset($labels['uuid'])): ?> |
|
128 | 128 | $behaviors['uuid'] = [ |
129 | 129 | 'class' => AttributeBehavior::className(), |
130 | 130 | 'attributes' => [ |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function rules() |
168 | 168 | { |
169 | - return [<?= "\n " . implode(",\n ", $rules) . ",\n " ?> <?php if(isset($labels['status'])): ?>// status rule |
|
169 | + return [<?= "\n " . implode(",\n ", $rules) . ",\n " ?> <?php if (isset($labels['status'])): ?>// status rule |
|
170 | 170 | ['status', 'default', 'value' => self::STATUS_REVIEW], |
171 | 171 | ['status', 'in', 'range' => [self::STATUS_DRAFT, self::STATUS_REVIEW, self::STATUS_REJECTED, self::STATUS_PUBLISHED]],<?php endif; ?> |
172 | 172 | ]; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | { |
216 | 216 | return $this->user_id == Yii::$app->user->id; |
217 | 217 | } |
218 | -<?php if(isset($labels['status'])): ?> |
|
218 | +<?php if (isset($labels['status'])): ?> |
|
219 | 219 | /** |
220 | 220 | * 是否草稿状态 |
221 | 221 | * @return bool |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ])); |
365 | 365 | return $total; |
366 | 366 | } |
367 | -<?php if(isset($labels['created_at'])): ?> |
|
367 | +<?php if (isset($labels['created_at'])): ?> |
|
368 | 368 | |
369 | 369 | /** |
370 | 370 | * 获取模型今日新增总数 |
@@ -26,16 +26,16 @@ |
||
26 | 26 | return [ |
27 | 27 | 'id', |
28 | 28 | 'nickname', |
29 | - 'faceUrl' => function () { |
|
29 | + 'faceUrl' => function() { |
|
30 | 30 | return $this->getAvatar(AvatarHelper::AVATAR_MIDDLE); |
31 | 31 | }, |
32 | - "created_datetime" => function () { |
|
32 | + "created_datetime" => function() { |
|
33 | 33 | return gmdate(DATE_ISO8601, $this->created_at); |
34 | 34 | }, |
35 | - "updated_datetime" => function () { |
|
35 | + "updated_datetime" => function() { |
|
36 | 36 | return gmdate(DATE_ISO8601, $this->updated_at); |
37 | 37 | }, |
38 | - 'blocked_datetime' => function () { |
|
38 | + 'blocked_datetime' => function() { |
|
39 | 39 | return gmdate(DATE_ISO8601, $this->blocked_at); |
40 | 40 | } |
41 | 41 | ]; |
@@ -68,7 +68,7 @@ |
||
68 | 68 | return [ |
69 | 69 | [['ruleName'], 'checkRule'], |
70 | 70 | [['name', 'type'], 'required'], |
71 | - [['name'], 'checkUnique', 'when' => function () { |
|
71 | + [['name'], 'checkUnique', 'when' => function() { |
|
72 | 72 | return $this->isNewRecord || ($this->_item->name != $this->name); |
73 | 73 | }], |
74 | 74 | [['type'], 'integer'], |