2015-10-28 21:22:07 +02:00
|
|
|
<?php namespace App\Services;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Bus\DispatchesCommands;
|
|
|
|
|
|
|
|
|
|
class BaseService
|
|
|
|
|
{
|
|
|
|
|
use DispatchesCommands;
|
|
|
|
|
|
|
|
|
|
protected function getRepo()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-29 16:42:05 +02:00
|
|
|
public function bulk($ids, $action)
|
2015-10-28 21:22:07 +02:00
|
|
|
{
|
|
|
|
|
if ( ! $ids) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$entities = $this->getRepo()->findByPublicIdsWithTrashed($ids);
|
|
|
|
|
|
|
|
|
|
foreach ($entities as $entity) {
|
2015-10-29 16:42:05 +02:00
|
|
|
$this->getRepo()->$action($entity);
|
2015-10-28 21:22:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return count($entities);
|
|
|
|
|
}
|
|
|
|
|
}
|