1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00
invoiceninja/app/Services/BaseService.php
2019-01-30 22:25:37 +11: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);
}
}