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