model = $payments; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(PaymentsAdminRequest $request) { if ($request->wantsJson()) { $array = $this->model->json(); foreach ($array as $key => $row) { $array[$key] = array_only($row, config('payment.payments.listfields')); } return ['data' => $array]; } $this->theme->prependTitle(trans('payment::payments.names').' :: '); return $this->theme->of('payment::admin.payments.index')->render(); } /** * Display the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function show(PaymentsAdminRequest $request, $id) { $payments = $this->model->find($id); if (empty($payments)) { if ($request->wantsJson()) { return []; } return view('payment::admin.payments.new'); } if ($request->wantsJson()) { return $payments; } Former::populate($payments); return view('payment::admin.payments.show', compact('payments')); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(PaymentsAdminRequest $request) { $payments = $this->model->findOrNew(0); Former::populate($payments); return view('payment::admin.payments.create', compact('payments')); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(PaymentsAdminRequest $request) { try { $attributes = $request->all(); $payments = $this->model->create($attributes); return $this->success(trans('messages.success.created', ['Module' => trans('payment::payments.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function edit(PaymentsAdminRequest $request, $id) { $payments = $this->model->find($id); Former::populate($payments); return view('payment::admin.payments.edit', compact('payments')); } /** * Update the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function update(PaymentsAdminRequest $request, $id) { try { $attributes = $request->all(); $payments = $this->model->update($attributes, $id); return $this->success(trans('messages.success.updated', ['Module' => trans('payment::payments.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(PaymentsAdminRequest $request, $id) { try { $this->model->delete($id); return $this->success(trans('message.success.deleted', ['Module' => trans('payment::payments.name')]), 200); } catch (Exception $e) { return $this->error($e->getMessage()); } } }