1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Services/BaseService.php
2016-05-23 19:52:20 +03:00

34 lines
623 B
PHP

<?php namespace App\Services;
use Auth;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Services\DatatableService;
class BaseService
{
use DispatchesJobs;
protected function getRepo()
{
return null;
}
public function bulk($ids, $action)
{
if ( ! $ids ) {
return 0;
}
$entities = $this->getRepo()->findByPublicIdsWithTrashed($ids);
foreach ($entities as $entity) {
if(Auth::user()->can('edit', $entity)){
$this->getRepo()->$action($entity);
}
}
return count($entities);
}
}