repository = $workflow; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Project\Role\Repositories\Criteria\WorkflowResourceCriteria::class); } /** * Display a list of workflow. * * @return Response */ public function index(WorkflowRequest $request) { return $this->repository ->setPresenter(\Project\Role\Repositories\Presenter\WorkflowPresenter::class) ->paginate(); } /** * Display workflow. * * @param Request $request * @param Model $workflow * * @return Response */ public function show(WorkflowRequest $request, Workflow $workflow) { return $workflow->setPresenter(\Project\Role\Repositories\Presenter\WorkflowListPresenter::class); ; } /** * Create new workflow. * * @param Request $request * * @return Response */ public function store(WorkflowRequest $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('role::workflow.name')]); $code = 204; $status = 'success'; $url = guard_url('role/workflow/' . $workflow->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('role/workflow'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the workflow. * * @param Request $request * @param Model $workflow * * @return Response */ public function update(WorkflowRequest $request, Workflow $workflow) { try { $data = $request->all(); $workflow->update($data); $message = trans('messages.success.updated', ['Module' => trans('role::workflow.name')]); $code = 204; $status = 'success'; $url = guard_url('role/workflow/' . $workflow->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('role/workflow/' . $workflow->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the workflow. * * @param Model $workflow * * @return Response */ public function destroy(WorkflowRequest $request, Workflow $workflow) { try { $workflow->delete(); $message = trans('messages.success.deleted', ['Module' => trans('role::workflow.name')]); $code = 202; $status = 'success'; $url = guard_url('role/workflow/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('role/workflow/' . $workflow->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); } }