repository = $scheduler; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\B2buy\Scheduler\Repositories\Criteria\SchedulerResourceCriteria::class); } /** * Display a list of scheduler. * * @return Response */ public function index(SchedulerRequest $request) { return $this->repository ->setPresenter(\B2buy\Scheduler\Repositories\Presenter\SchedulerPresenter::class) ->paginate(); } /** * Display scheduler. * * @param Request $request * @param Model $scheduler * * @return Response */ public function show(SchedulerRequest $request, Scheduler $scheduler) { return $scheduler->setPresenter(\B2buy\Scheduler\Repositories\Presenter\SchedulerListPresenter::class); ; } /** * Create new scheduler. * * @param Request $request * * @return Response */ public function store(SchedulerRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('scheduler::scheduler.name')]); $code = 204; $status = 'success'; $url = guard_url('scheduler/scheduler/' . $scheduler->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('scheduler/scheduler'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the scheduler. * * @param Request $request * @param Model $scheduler * * @return Response */ public function update(SchedulerRequest $request, Scheduler $scheduler) { try { $data = $request->all(); $scheduler->update($data); $message = trans('messages.success.updated', ['Module' => trans('scheduler::scheduler.name')]); $code = 204; $status = 'success'; $url = guard_url('scheduler/scheduler/' . $scheduler->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('scheduler/scheduler/' . $scheduler->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the scheduler. * * @param Model $scheduler * * @return Response */ public function destroy(SchedulerRequest $request, Scheduler $scheduler) { try { $scheduler->delete(); $message = trans('messages.success.deleted', ['Module' => trans('scheduler::scheduler.name')]); $code = 202; $status = 'success'; $url = guard_url('scheduler/scheduler/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('scheduler/scheduler/' . $scheduler->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }