prevent deletion of WP Users segment in Segments listing
This commit is contained in:
@ -72,7 +72,7 @@ class Model extends \Sudzy\ValidModel {
|
||||
static function bulkTrash($orm) {
|
||||
$model = get_called_class();
|
||||
return self::bulkAction($orm, function($ids) use($model) {
|
||||
self::rawExecute(join(' ', array(
|
||||
self::rawExecute(join(' ', array(
|
||||
'UPDATE `'.$model::$_table.'`',
|
||||
'SET `deleted_at`=NOW()',
|
||||
'WHERE `id` IN ('.rtrim(str_repeat('?,', count($ids)), ',').')'
|
||||
|
@ -190,4 +190,24 @@ class Segment extends Model {
|
||||
static function getPublic() {
|
||||
return self::getPublished()->where('type', 'default')->orderByAsc('name');
|
||||
}
|
||||
|
||||
static function bulkTrash($orm) {
|
||||
return parent::bulkAction($orm, function($ids) {
|
||||
parent::rawExecute(join(' ', array(
|
||||
'UPDATE `'.self::$_table.'`',
|
||||
'SET `deleted_at`=NOW()',
|
||||
'WHERE `id` IN ('.rtrim(str_repeat('?,', count($ids)), ',').')',
|
||||
'AND `type` = "default"'
|
||||
)), $ids);
|
||||
});
|
||||
}
|
||||
|
||||
static function bulkDelete($orm) {
|
||||
return parent::bulkAction($orm, function($ids) {
|
||||
// delete segments (only default)
|
||||
Segment::whereIn('id', $ids)
|
||||
->where('type', 'default')
|
||||
->deleteMany();
|
||||
});
|
||||
}
|
||||
}
|
@ -597,7 +597,7 @@ class Subscriber extends Model {
|
||||
|
||||
static function bulkTrash($orm) {
|
||||
return parent::bulkAction($orm, function($ids) {
|
||||
parent::rawExecute(join(' ', array(
|
||||
parent::rawExecute(join(' ', array(
|
||||
'UPDATE `'.self::$_table.'`',
|
||||
'SET `deleted_at`=NOW()',
|
||||
'WHERE `id` IN ('.rtrim(str_repeat('?,', count($ids)), ',').')',
|
||||
|
Reference in New Issue
Block a user