Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
5d7e7f4d
Commit
5d7e7f4d
authored
Feb 04, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved creating user to static method of the model
parent
b8f14b06
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
User.php
apps/advanced/common/models/User.php
+12
-0
SignupForm.php
apps/advanced/frontend/models/forms/SignupForm.php
+1
-4
No files found.
apps/advanced/common/models/User.php
View file @
5d7e7f4d
...
@@ -27,6 +27,18 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -27,6 +27,18 @@ class User extends ActiveRecord implements IdentityInterface
const
ROLE_USER
=
10
;
const
ROLE_USER
=
10
;
public
static
function
create
(
$attributes
)
{
/** @var User $user */
$user
=
new
static
();
$user
->
setAttributes
(
$attributes
);
if
(
$user
->
save
())
{
return
$user
;
}
else
{
return
null
;
}
}
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
...
apps/advanced/frontend/models/forms/SignupForm.php
View file @
5d7e7f4d
...
@@ -41,10 +41,7 @@ class SignupForm extends Model
...
@@ -41,10 +41,7 @@ class SignupForm extends Model
public
function
signup
()
public
function
signup
()
{
{
if
(
$this
->
validate
())
{
if
(
$this
->
validate
())
{
$user
=
User
::
create
(
$this
->
attributes
);
return
User
::
create
(
$this
->
attributes
);
if
(
$user
->
save
())
{
return
$user
;
}
}
}
return
null
;
return
null
;
}
}
...
...
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