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