Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
7e8ac033
Commit
7e8ac033
authored
Oct 18, 2016
by
xiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加from
parent
93389443
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
User.php
src/common/models/User.php
+7
-6
m160927_104153_users_init.php
src/console/migrations/m160927_104153_users_init.php
+1
-0
No files found.
src/common/models/User.php
View file @
7e8ac033
...
@@ -76,7 +76,7 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -76,7 +76,7 @@ class User extends ActiveRecord implements IdentityInterface
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'username'
,
'auth_key'
,
'password_hash'
,
'telephone'
,
'ip'
,
'logged_at'
],
'required'
],
[[
'username'
,
'auth_key'
,
'password_hash'
,
'telephone'
,
'ip'
,
'
from'
,
'
logged_at'
],
'required'
],
[[
'role'
,
'status'
],
'integer'
],
[[
'role'
,
'status'
],
'integer'
],
[[
'created_at'
,
'updated_at'
,
'logged_at'
],
'safe'
],
[[
'created_at'
,
'updated_at'
,
'logged_at'
],
'safe'
],
[[
'username'
,
'auth_key'
,
'wx_open_id'
,
'ip'
],
'string'
,
'max'
=>
32
],
[[
'username'
,
'auth_key'
,
'wx_open_id'
,
'ip'
],
'string'
,
'max'
=>
32
],
...
@@ -106,6 +106,7 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -106,6 +106,7 @@ class User extends ActiveRecord implements IdentityInterface
'avatar'
=>
'avatar'
,
'avatar'
=>
'avatar'
,
'wx_open_id'
=>
'wx_open_id'
,
'wx_open_id'
=>
'wx_open_id'
,
'ip'
=>
'ip'
,
'ip'
=>
'ip'
,
'from'
=>
'from'
,
'created_at'
=>
'created_at'
,
'created_at'
=>
'created_at'
,
'updated_at'
=>
'updated_at'
,
'updated_at'
=>
'updated_at'
,
'logged_at'
=>
'logged_at'
,
'logged_at'
=>
'logged_at'
,
...
@@ -177,22 +178,22 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -177,22 +178,22 @@ class User extends ActiveRecord implements IdentityInterface
/**
/**
* 获取用户头像 URL
* 获取用户头像 URL
*
*
* @param string $avatar
* @param string $avatar
* @param string $size 头像尺寸,目前仅支持 m,留空返回原图
* @param string $size 头像尺寸,目前仅支持 m,留空返回原图
* @return string
* @return string
*/
*/
public
static
function
getAvatarUrl
(
$avatar
,
$size
=
'm'
)
public
static
function
getAvatarUrl
(
$avatar
,
$size
=
'm'
)
{
{
if
(
!
$avatar
)
{
if
(
!
$avatar
)
{
return
\frontend\assets\AppAsset
::
getStaticUrl
(
'img/avatarMax.png'
)
;
return
\frontend\assets\AppAsset
::
getStaticUrl
(
'img/avatarMax.png'
);
}
}
$url
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$avatar
);
$url
=
Yii
::
$app
->
qiniu
->
getUrl
(
'public'
,
$avatar
);
return
$size
?
$url
.
"-
{
$size
}
.avatar"
:
$url
;
return
$size
?
$url
.
"-
{
$size
}
.avatar"
:
$url
;
}
}
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
...
src/console/migrations/m160927_104153_users_init.php
View file @
7e8ac033
...
@@ -26,6 +26,7 @@ class m160927_104153_users_init extends Migration
...
@@ -26,6 +26,7 @@ class m160927_104153_users_init extends Migration
'avatar'
=>
$this
->
string
(
128
)
->
notNull
()
->
defaultValue
(
''
),
'avatar'
=>
$this
->
string
(
128
)
->
notNull
()
->
defaultValue
(
''
),
'wx_open_id'
=>
$this
->
string
(
32
)
->
defaultValue
(
''
)
->
comment
(
'登录微信id'
),
'wx_open_id'
=>
$this
->
string
(
32
)
->
defaultValue
(
''
)
->
comment
(
'登录微信id'
),
'ip'
=>
$this
->
string
(
32
)
->
notNull
(),
'ip'
=>
$this
->
string
(
32
)
->
notNull
(),
'from'
=>
$this
->
init
()
->
unsigned
()
->
defaultValue
(
0
)
->
comment
(
'0 来自注册 其它为某个user_id'
),
'created_at'
=>
$this
->
integer
()
->
notNull
(),
'created_at'
=>
$this
->
integer
()
->
notNull
(),
'updated_at'
=>
$this
->
integer
()
->
notNull
(),
'updated_at'
=>
$this
->
integer
()
->
notNull
(),
'logged_at'
=>
$this
->
integer
()
->
notNull
()
'logged_at'
=>
$this
->
integer
()
->
notNull
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment