Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
Y
yii2-softdelete
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
digisin
yii2-softdelete
Commits
efa5f6bf
Commit
efa5f6bf
authored
Feb 21, 2017
by
Brett O'Donnell
Committed by
GitHub
Feb 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update SoftDeleteQueryBehavior.php
parent
221adfed
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
SoftDeleteQueryBehavior.php
src/SoftDeleteQueryBehavior.php
+15
-14
No files found.
src/SoftDeleteQueryBehavior.php
View file @
efa5f6bf
<?php
<?php
/**
* @author Brett O'Donnell <cornernote@gmail.com>
* @copyright 2015 Mr PHP
* @link https://github.com/cornernote/yii2-softdelete
* @license BSD-3-Clause https://raw.github.com/cornernote/yii2-softdelete/master/LICENSE.md
*/
namespace
cornernote\softdelete
;
namespace
cornernote\softdelete
;
...
@@ -28,6 +22,8 @@ use yii\db\ActiveRecord;
...
@@ -28,6 +22,8 @@ use yii\db\ActiveRecord;
* ```
* ```
*
*
* @property ActiveQuery $owner
* @property ActiveQuery $owner
*
* @author cornernote <cornernote@gmail.com>
*/
*/
class
SoftDeleteQueryBehavior
extends
Behavior
class
SoftDeleteQueryBehavior
extends
Behavior
{
{
...
@@ -37,24 +33,29 @@ class SoftDeleteQueryBehavior extends Behavior
...
@@ -37,24 +33,29 @@ class SoftDeleteQueryBehavior extends Behavior
public
$attribute
=
'deleted_at'
;
public
$attribute
=
'deleted_at'
;
/**
/**
* @return
ActiveQuery
* @return
static
*/
*/
public
function
deleted
()
public
function
deleted
()
{
{
/** @var ActiveRecord $modelClass */
return
$this
->
owner
->
andWhere
(
$this
->
tableName
()
.
'.'
.
$this
->
attribute
.
' IS NOT NULL'
);
$modelClass
=
$this
->
owner
->
modelClass
;
$tableName
=
$modelClass
::
tableName
();
return
$this
->
owner
->
andWhere
(
$tableName
.
'.'
.
$this
->
attribute
.
' IS NOT NULL'
);
}
}
/**
/**
* @return
ActiveQuery
* @return
static
*/
*/
public
function
notDeleted
()
public
function
notDeleted
()
{
return
$this
->
owner
->
andWhere
(
$this
->
tableName
()
.
'.'
.
$this
->
attribute
.
' IS NULL'
);
}
/**
* @return string
*/
protected
function
tableName
()
{
{
/** @var ActiveRecord $modelClass */
/** @var ActiveRecord $modelClass */
$modelClass
=
$this
->
owner
->
modelClass
;
$modelClass
=
$this
->
owner
->
modelClass
;
$tableName
=
$modelClass
::
tableName
();
return
$modelClass
::
tableName
();
return
$this
->
owner
->
andWhere
(
$tableName
.
'.'
.
$this
->
attribute
.
' IS 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