Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
77af80be
Commit
77af80be
authored
Apr 28, 2016
by
Shakarim Sapa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Добавлены методы, для полноценной работы подписок на кейсы
parent
66d011d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
1 deletion
+49
-1
common/modules/cases/models/CasesBids.php
common/modules/cases/models/CasesBids.php
+49
-1
No files found.
common/modules/cases/models/CasesBids.php
View file @
77af80be
...
@@ -2,7 +2,10 @@
...
@@ -2,7 +2,10 @@
namespace
common\modules\cases\models
;
namespace
common\modules\cases\models
;
use
common\components\ActiveRecordModel
;
use
common\modules\triggers\models\CasesSchedule
;
use
Yii
;
use
Yii
;
use
common\modules\users\models\User
;
/**
/**
* This is the model class for table "cases_bids".
* This is the model class for table "cases_bids".
...
@@ -11,7 +14,7 @@ use Yii;
...
@@ -11,7 +14,7 @@ use Yii;
* @property string $email
* @property string $email
* @property string $date
* @property string $date
*/
*/
class
CasesBids
extends
\yii\db\ActiveRecord
class
CasesBids
extends
ActiveRecordModel
{
{
/**
/**
* @inheritdoc
* @inheritdoc
...
@@ -21,6 +24,13 @@ class CasesBids extends \yii\db\ActiveRecord
...
@@ -21,6 +24,13 @@ class CasesBids extends \yii\db\ActiveRecord
return
'cases_bids'
;
return
'cases_bids'
;
}
}
/**
* @inheritdoc
*/
public
function
name
()
{
return
'Подписка на кейсы'
;
}
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
@@ -28,11 +38,49 @@ class CasesBids extends \yii\db\ActiveRecord
...
@@ -28,11 +38,49 @@ class CasesBids extends \yii\db\ActiveRecord
{
{
return
[
return
[
[[
'email'
,
'date'
],
'required'
],
[[
'email'
,
'date'
],
'required'
],
[[
'email'
],
'unique'
,
'message'
=>
'Вы уже подписаны на новости блога'
],
[[
'date'
],
'safe'
],
[[
'date'
],
'safe'
],
[[
'email'
],
'string'
,
'max'
=>
255
],
[[
'email'
],
'string'
,
'max'
=>
255
],
];
];
}
}
/**
* @param bool $insert
* @param array $changedAttributes
* @return bool
*/
public
function
afterSave
(
$insert
,
$changedAttributes
)
{
parent
::
afterSave
(
$insert
,
$changedAttributes
);
if
(
!
is_null
(
$this
->
email
))
{
/** @var User $user */
$user
=
User
::
find
()
->
where
([
'email'
=>
$this
->
email
])
->
one
();
if
(
!
is_null
(
$user
))
{
$user
->
afterSubscribe
([
'email'
=>
$this
->
email
],
true
);
}
Yii
::
$app
->
cache
->
set
(
'user_email'
,
$this
->
email
);
}
}
/**
* @return bool
*/
public
function
beforeDelete
(){
if
(
!
parent
::
beforeDelete
())
return
false
;
CasesSchedule
::
deleteAll
([
'email'
=>
$this
->
email
]);
return
true
;
}
/**
* @return array
*/
public
function
behaviors
(){
return
[];
}
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
...
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