fix bulk actions and messages

This commit is contained in:
Jonathan Labreuille
2016-09-06 17:21:15 +02:00
parent f650455a90
commit 4a72995bf4
17 changed files with 207 additions and 175 deletions

View File

@@ -77,7 +77,7 @@ class Model extends \Sudzy\ValidModel {
static function bulkTrash($orm) {
$model = get_called_class();
return self::bulkAction($orm, function($ids) use($model) {
$count = self::bulkAction($orm, function($ids) use($model) {
self::rawExecute(join(' ', array(
'UPDATE `'.$model::$_table.'`',
'SET `deleted_at` = NOW()',
@@ -86,13 +86,17 @@ class Model extends \Sudzy\ValidModel {
$ids
);
});
return array('count' => $count);
}
static function bulkDelete($orm) {
$model = get_called_class();
return self::bulkAction($orm, function($ids) use($model) {
$count = self::bulkAction($orm, function($ids) use($model) {
$model::whereIn('id', $ids)->deleteMany();
});
return array('count' => $count);
}
function restore() {
@@ -101,7 +105,7 @@ class Model extends \Sudzy\ValidModel {
static function bulkRestore($orm) {
$model = get_called_class();
return self::bulkAction($orm, function($ids) use($model) {
$count = self::bulkAction($orm, function($ids) use($model) {
self::rawExecute(join(' ', array(
'UPDATE `'.$model::$_table.'`',
'SET `deleted_at` = NULL',
@@ -110,6 +114,8 @@ class Model extends \Sudzy\ValidModel {
$ids
);
});
return array('count' => $count);
}
static function bulkAction($orm, $callback = false) {