1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/app/Services/BaseService.php
2016-08-02 17:38:51 +03:00

43 lines
730 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);
}
}