all()); $message = trans('messages.success.added', ['type' => trans_choice('general.tax_rates', 1)]); flash($message)->success(); return redirect('settings/taxes'); } /** * Show the form for editing the specified resource. * * @param Tax $tax * * @return Response */ public function edit(Tax $tax) { return view('settings.taxes.edit', compact('tax')); } /** * Update the specified resource in storage. * * @param Tax $tax * @param Request $request * * @return Response */ public function update(Tax $tax, Request $request) { $tax->update($request->all()); $message = trans('messages.success.updated', ['type' => trans_choice('general.tax_rates', 1)]); flash($message)->success(); return redirect('settings/taxes'); } /** * Remove the specified resource from storage. * * @param Tax $tax * * @return Response */ public function destroy(Tax $tax) { $canDelete = $tax->canDelete(); if ($canDelete === true) { $tax->delete(); $message = trans('messages.success.deleted', ['type' => trans_choice('general.taxes', 1)]); flash($message)->success(); } else { $text = array(); if (isset($canDelete['items'])) { $text[] = '' . $canDelete['items'] . ' ' . trans_choice('general.items', ($canDelete['items'] > 1) ? 2 : 1); } if (isset($canDelete['bills'])) { $text[] = '' . $canDelete['bills'] . ' ' . trans_choice('general.bills', ($canDelete['bills'] > 1) ? 2 : 1); } if (isset($canDelete['invoices'])) { $text[] = '' . $canDelete['invoices'] . ' ' . trans_choice('general.items', ($canDelete['invoices'] > 1) ? 2 : 1); } $message = trans('messages.warning.deleted', ['type' => trans_choice('general.taxes', 1), 'text' => implode(', ', $text)]); flash($message)->warning(); } return redirect('settings/taxes'); } }