Code refactoring
This commit is contained in:
@ -93,19 +93,12 @@ class Companies extends Controller
|
||||
// Save all settings
|
||||
setting()->save();
|
||||
|
||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.companies', 2)]);
|
||||
|
||||
$response = [
|
||||
return response()->json([
|
||||
'status' => null,
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => $message,
|
||||
'message' => trans('messages.success.updated', ['type' => trans_choice('general.companies', 2)]),
|
||||
'data' => null,
|
||||
'redirect' => route('wizard.currencies.index'),
|
||||
];
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return response()->json($response);
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -58,17 +58,10 @@ class Currencies extends Controller
|
||||
{
|
||||
$response = $this->ajaxDispatch(new CreateCurrency($request));
|
||||
|
||||
//$response['redirect'] = route('wizard.currencies.index');
|
||||
|
||||
if ($response['success']) {
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]);
|
||||
|
||||
//flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
//flash($message)->error()->important();
|
||||
}
|
||||
|
||||
$response['message'] = $message;
|
||||
@ -88,16 +81,10 @@ class Currencies extends Controller
|
||||
{
|
||||
$response = $this->ajaxDispatch(new UpdateCurrency($currency, $request));
|
||||
|
||||
// $response['redirect'] = route('wizard.currencies.index');
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.updated', ['type' => $currency->name]);
|
||||
|
||||
// flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
// flash($message)->error()->important();
|
||||
}
|
||||
|
||||
$response['message'] = $message;
|
||||
|
@ -34,7 +34,7 @@ class Data extends Controller
|
||||
public function index()
|
||||
{
|
||||
$translations = [
|
||||
'companies' => [
|
||||
'company' => [
|
||||
'title' => trans_choice('general.companies', 1),
|
||||
'api_key' => trans('modules.api_key'),
|
||||
'form_enter' => trans('general.form.enter'),
|
||||
@ -112,28 +112,37 @@ class Data extends Controller
|
||||
}
|
||||
|
||||
$taxes = Tax::collect();
|
||||
|
||||
$data = [
|
||||
|
||||
$modules = $this->getFeaturedModules([
|
||||
'query' => [
|
||||
'limit' => 4
|
||||
]
|
||||
];
|
||||
]);
|
||||
|
||||
$modules = $this->getFeaturedModules($data);
|
||||
$company = company();
|
||||
|
||||
$company = Company::find(company_id());
|
||||
$company->api_key = setting('apps.api_key');
|
||||
$company->financial_start = setting('localisation.financial_start');
|
||||
|
||||
if ($company->logo) {
|
||||
$logo = \Plank\Mediable\Media::find($company->logo);
|
||||
|
||||
$logo->path = route('uploads.get', $logo->id);
|
||||
|
||||
$company->logo = $logo;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'errors' => false,
|
||||
'message' => 'Get languages text..',
|
||||
'message' => 'Get all data...',
|
||||
'data' => [
|
||||
'translations' => $translations,
|
||||
'company' => $company,
|
||||
'currencies' => $currencies,
|
||||
'currency_codes' => $codes,
|
||||
'taxes' => $taxes,
|
||||
'modules' => $modules,
|
||||
'translations' => $translations,
|
||||
'companies' => $company,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
@ -46,17 +46,12 @@ class Taxes extends Controller
|
||||
{
|
||||
$response = $this->ajaxDispatch(new CreateTax($request));
|
||||
|
||||
// $response['redirect'] = route('wizard.taxes.index');
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.taxes', 1)]);
|
||||
|
||||
// flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
// flash($message)->error()->important();
|
||||
}
|
||||
|
||||
$response['message'] = $message;
|
||||
|
||||
return response()->json($response);
|
||||
@ -74,16 +69,10 @@ class Taxes extends Controller
|
||||
{
|
||||
$response = $this->ajaxDispatch(new UpdateTax($tax, $request));
|
||||
|
||||
// $response['redirect'] = route('wizard.taxes.index');
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.updated', ['type' => $tax->name]);
|
||||
|
||||
// flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
// flash($message)->error()->important();
|
||||
}
|
||||
|
||||
$response['message'] = $message;
|
||||
@ -104,17 +93,12 @@ class Taxes extends Controller
|
||||
|
||||
$response = $this->ajaxDispatch(new DeleteTax($tax));
|
||||
|
||||
// $response['redirect'] = route('wizard.taxes.index');
|
||||
|
||||
if ($response['success']) {
|
||||
$message = trans('messages.success.deleted', ['type' => $tax->name]);
|
||||
|
||||
// flash($message)->success();
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
// flash($message)->error()->important();
|
||||
}
|
||||
|
||||
$response['tax_id'] = $tax_id;
|
||||
$response['message'] = $message;
|
||||
|
||||
|
@ -1,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Wizard;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
|
||||
class Translations extends Controller
|
||||
{
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-common-companies')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-common-companies')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-common-companies')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-common-companies')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$translations = [
|
||||
'companies' => [
|
||||
'title' => trans_choice('general.companies', 1),
|
||||
'api_key' => trans('modules.api_key'),
|
||||
'form_enter' => trans('general.form.enter'),
|
||||
'get_api_key' => trans('modules.get_api_key'),
|
||||
'tax_number' => trans('general.tax_number'),
|
||||
'financial_start' => trans('settings.localisation.financial_start'),
|
||||
'address' => trans('settings.company.address'),
|
||||
'logo' => trans('settings.company.logo'),
|
||||
'skip' => trans('general.skip'),
|
||||
'save' => trans('general.save'),
|
||||
],
|
||||
|
||||
'currencies' => [
|
||||
'title' => trans_choice('general.currencies', 2),
|
||||
'add_new' => trans('general.add_new'),
|
||||
'name' => trans('general.name'),
|
||||
'code' => trans('currencies.code'),
|
||||
'rate' => trans('currencies.rate'),
|
||||
'enabled' => trans('general.enabled'),
|
||||
'actions' => trans('general.actions') ,
|
||||
'yes' => trans('general.yes'),
|
||||
'no' => trans('general.no'),
|
||||
'edit' => trans('general.edit'),
|
||||
'delete' => trans('general.delete'),
|
||||
'save' => trans('general.save'),
|
||||
'precision' => trans('currencies.precision'),
|
||||
'symbol' => trans('currencies.symbol.symbol'),
|
||||
'position' => trans('currencies.symbol.position'),
|
||||
'decimal_mark' => trans('currencies.decimal_mark'),
|
||||
'thousands_separator' => trans('currencies.thousands_separator'),
|
||||
'previous' => trans('pagination.previous'),
|
||||
'next' => trans('pagination.next'),
|
||||
'delete_confirm' => trans('general.delete_confirm'),
|
||||
'cancel' => trans('general.cancel'),
|
||||
],
|
||||
|
||||
'taxes' => [
|
||||
'title' => trans_choice('general.taxes', 2),
|
||||
'add_new' => trans('general.add_new'),
|
||||
'name' => trans('general.name'),
|
||||
'rate_percent' => trans('taxes.rate_percent'),
|
||||
'enabled' => trans('general.enabled'),
|
||||
'actions' => trans('general.actions'),
|
||||
'yes' => trans('general.yes'),
|
||||
'no' => trans('general.no'),
|
||||
'edit' => trans('general.edit'),
|
||||
'delete' => trans('general.delete'),
|
||||
'name' => trans('general.name'),
|
||||
'rate' => trans('currencies.rate'),
|
||||
'enabled' => trans('general.enabled'),
|
||||
'save' => trans('general.save'),
|
||||
'previous' => trans('pagination.previous'),
|
||||
'next' => trans('pagination.next'),
|
||||
'cancel' => trans('general.cancel'),
|
||||
],
|
||||
'finish' => [
|
||||
'title' => trans_choice('general.finish', 1),
|
||||
'recommended_apps' => trans('modules.recommended_apps'),
|
||||
'no_apps' => trans('modules.no_apps'),
|
||||
'developer' => trans('modules.developer'),
|
||||
'previous' => trans('pagination.previous'),
|
||||
'go_to_dashboard' => trans('general.go_to_dashboard'),
|
||||
]
|
||||
];
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'errors' => false,
|
||||
'message' => 'Get languages text..',
|
||||
'data' => $translations,
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user