123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace App\Services\Base;
- use App\Contracts\Repositories\Base\AreaRepository;
- use App\Repositories\Criteria\Base\AreaCriteria;
- use App\Repositories\Eloquent\Base\AreaRepositoryEloquent;
- use App\Repositories\Presenters\Base\AreaPresenter;
- use Illuminate\Http\Request;
- class AreaService
- {
- /**
- * @var AreaRepositoryEloquent
- */
- private $areaRepository;
- /**
- * AreaService constructor.
- *
- * @param AreaRepositoryEloquent $areaRepositoryEloquent
- */
- public function __construct(AreaRepositoryEloquent $areaRepositoryEloquent)
- {
- $this->areaRepository = $areaRepositoryEloquent;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function handleList(Request $request)
- {
- $this->areaRepository->pushCriteria(new AreaCriteria($request));
- $this->areaRepository->setPresenter(AreaPresenter::class);
- return $this->areaRepository->searchAreasByPage();
- }
- /**
- * @param $id
- *
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function handleProfile($id)
- {
- $this->areaRepository->setPresenter(AreaPresenter::class);
- return $this->areaRepository->searchAreaBy($id);
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleStore($data)
- {
- $area = $this->areaRepository->create($data);
- return $area;
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleUpdate($data)
- {
- $area = $this->areaRepository->update($data, $data['id']);
- return $area;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleDelete($id)
- {
- return $this->areaRepository->delete($id);
- }
- }
|