1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Services/BaseService.php
2017-01-30 21:40:43 +02:00

46 lines
737 B
PHP

<?php
namespace App\Services;
use Auth;
use Illuminate\Foundation\Bus\DispatchesJobs;
/**
* Class BaseService.
*/
class BaseService
{
use DispatchesJobs;
/**
* @return null
*/
protected function getRepo()
{
return null;
}
/**
* @param $ids
* @param $action
*
* @return int
*/
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);
}
}