123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace App\Services\Wechat;
- use App\Contracts\Repositories\Wechat\AccountRepository;
- use App\Repositories\Criteria\Wechat\AccountCriteria;
- use App\Repositories\Eloquent\Wechat\AccountRepositoryEloquent;
- use App\Repositories\Presenters\Wechat\AccountPresenter;
- use Illuminate\Http\Request;
- class AccountService
- {
- /**
- * @var AccountRepositoryEloquent
- */
- private $accountRepository;
- /**
- * AccountService constructor.
- *
- * @param AccountRepositoryEloquent $accountRepositoryEloquent
- */
- public function __construct(AccountRepositoryEloquent $accountRepositoryEloquent)
- {
- $this->accountRepository = $accountRepositoryEloquent;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function handleList(Request $request)
- {
- $this->accountRepository->pushCriteria(new AccountCriteria($request));
- $this->accountRepository->setPresenter(AccountPresenter::class);
- return $this->accountRepository->searchAccountsByPage();
- }
- /**
- * @param $id
- *
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function handleProfile($id)
- {
- $this->accountRepository->setPresenter(AccountPresenter::class);
- return $this->accountRepository->searchAccountBy($id);
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleStore($data)
- {
- $account = $this->accountRepository->create($data);
- return $account;
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleUpdate($data)
- {
- $account = $this->accountRepository->update($data,$data['id']);
- return $account;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleDelete($id)
- {
- return $this->accountRepository->delete($id);
- }
- }
|