-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows programmatic toggling of soft deletes
- Loading branch information
Showing
3 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php namespace October\Rain\Database\Scopes; | ||
|
||
use Illuminate\Database\Eloquent\SoftDeletingScope; | ||
use Illuminate\Database\Eloquent\Model as ModelBase; | ||
use Illuminate\Database\Eloquent\Builder as BuilderBase; | ||
|
||
/** | ||
* SoftDeleteScope | ||
* | ||
* @package october\database | ||
* @author Alexey Bobkov, Samuel Georges | ||
*/ | ||
class SoftDeleteScope extends SoftDeletingScope | ||
{ | ||
/** | ||
* apply the scope to a given Eloquent query builder. | ||
*/ | ||
public function apply(BuilderBase $builder, ModelBase $model) | ||
{ | ||
if ($model->isSoftDeleteEnabled()) { | ||
$builder->whereNull($model->getQualifiedDeletedAtColumn()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters