123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace App\Services\Course;
- use App\Repositories\Criteria\Course\AttachCriteria;
- use App\Repositories\Eloquent\Course\AttachRepositoryEloquent;
- use App\Repositories\Presenters\Course\AttachPresenter;
- use Illuminate\Http\Request;
- class AttachService
- {
- /**
- * @var AttachRepositoryEloquent
- */
- private $attachRepository;
- /**
- * AttachService constructor.
- *
- * @param AttachRepositoryEloquent $attachRepositoryEloquent
- */
- public function __construct(AttachRepositoryEloquent $attachRepositoryEloquent)
- {
- $this->attachRepository = $attachRepositoryEloquent;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function handleList(Request $request)
- {
- $this->attachRepository->pushCriteria(new AttachCriteria($request));
- $this->attachRepository->setPresenter(AttachPresenter::class);
- return $this->attachRepository->searchAttachsByPage();
- }
- /**
- * @param $id
- *
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function handleProfile($id)
- {
- $this->attachRepository->setPresenter(AttachPresenter::class);
- return $this->attachRepository->searchAttachBy($id);
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleStore($data)
- {
- $attach = $this->attachRepository->create($data);
- return $attach;
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleUpdate($data)
- {
- $attach = $this->attachRepository->update($data, $data['id']);
- return $attach;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleDelete($id)
- {
- return $this->attachRepository->delete($id);
- }
- /**
- * 选项
- * @param Request $request
- * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Support\Collection|mixed
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function handleSelectOptions(Request $request)
- {
- $this->attachRepository->pushCriteria(new AttachCriteria($request));
- return $this->attachRepository->all(['id', 'name']);
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function handleAll(Request $request)
- {
- $this->attachRepository->pushCriteria(new AttachCriteria($request));
- $this->attachRepository->setPresenter(AttachPresenter::class);
- return $this->attachRepository->get();
- }
- }
|