123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace App\Services\Mentor;
- use App\Contracts\Repositories\Mentor\StudentRepository;
- use App\Repositories\Criteria\Mentor\StudentCriteria;
- use App\Repositories\Eloquent\Mentor\StudentRepositoryEloquent;
- use App\Repositories\Presenters\Mentor\StudentPresenter;
- use Illuminate\Http\Request;
- class StudentService
- {
- /**
- * @var StudentRepositoryEloquent
- */
- private $studentRepository;
- /**
- * StudentService constructor.
- *
- * @param StudentRepositoryEloquent $studentRepositoryEloquent
- */
- public function __construct(StudentRepositoryEloquent $studentRepositoryEloquent)
- {
- $this->studentRepository = $studentRepositoryEloquent;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function handleList(Request $request)
- {
- $this->studentRepository->pushCriteria(new StudentCriteria($request));
- $this->studentRepository->setPresenter(StudentPresenter::class);
- return $this->studentRepository->searchStudentsByPage();
- }
- /**
- * @param $id
- *
- * @return \Illuminate\Database\Eloquent\Model
- */
- public function handleProfile($id)
- {
- $this->studentRepository->setPresenter(StudentPresenter::class);
- return $this->studentRepository->searchStudentBy($id);
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleStore($data)
- {
- $student = $this->studentRepository->create($data);
- return $student;
- }
- /**
- * @param array $data
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleUpdate($data)
- {
- $student = $this->studentRepository->update($data, $data['id']);
- return $student;
- }
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws \Prettus\Validator\Exceptions\ValidatorException
- */
- public function handleDelete($id)
- {
- return $this->studentRepository->delete($id);
- }
- public function handleSelectOptions(Request $request)
- {
- $this->studentRepository->pushCriteria(new StudentCriteria($request));
- return $this->studentRepository->all(['id', 'truename', 'account']);
- }
- }
|