123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace App\Services\Wechat;
- use App\Contracts\Repositories\Wechat\EventRepository;
- use App\Repositories\Criteria\Wechat\EventCriteria;
- use App\Repositories\Eloquent\Wechat\EventRepositoryEloquent;
- use App\Repositories\Presenters\Wechat\EventPresenter;
- use Illuminate\Http\Request;
- class EventService
- {
- /**
- * @var EventRepositoryEloquent
- */
- private $eventRepository;
- /**
- * EventService constructor.
- *
- * @param EventRepositoryEloquent $eventRepositoryEloquent
- */
- public function __construct(EventRepositoryEloquent $eventRepositoryEloquent)
- {
- $this->eventRepository = $eventRepositoryEloquent;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function handleList(Request $request)
- {
- $this->eventRepository->pushCriteria(new EventCriteria($request));
- $this->eventRepository->setPresenter(EventPresenter::class);
- return $this->eventRepository->searchEventsByPage();
- }
- /**
- * @param $id
- *
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function handleProfile($id)
- {
- $this->eventRepository->setPresenter(EventPresenter::class);
- return $this->eventRepository->searchEventBy($id);
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleStore($data)
- {
- $event = $this->eventRepository->create($data);
- return $event;
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleUpdate($data)
- {
- $event = $this->eventRepository->update($data,$data['id']);
- return $event;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleDelete($id)
- {
- return $this->eventRepository->delete($id);
- }
- }
|