Skip to content

chenpkg/laravel-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laravel-helpers

laravel helpers.

功能

  • Scope 模型查询作用域构建
  • Batch 模型批量修改
  • Tree 模型无限极分类树
  • MetaPaginator 模型分页自定义添加数据

安装

$ composer require chenpkg/laravel-helpers

使用

Batch 批量修改

功能来源于 laravelBatch

use LaravelHelpers\Support\Batch;

$update = [
    [
        'id'   => 1,
        'name' => '李四'
    ],
    [
        'id'   => 5,
        'name' => '小红'
    ],
    [
        'id'   => 5,
        'name' => '李雷雷'
    ]
];

Batch::update(new User(), $update, 'id');

MetaPaginator

// 分页添加自定义数据
$result = User::where('age', '>', 18)->metaPaginate();

$result->addMeta('count', 1)->addMeta('total', 1000);
// or
$result->setMeta([
  'count' => 1,
  'total' => 1000
]);

License

MIT