update marketing
All checks were successful
All checks were successful
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace Modules\Business\App\Http\Controllers;
|
||||
|
||||
use App\Models\Option;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ProductSetting;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Option;
|
||||
use App\Models\ProductSetting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
@@ -14,23 +14,29 @@ class AcnooSettingsManagerController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$businessId = auth()->user()->business_id;
|
||||
$invoiceSettingKey = 'invoice_setting_' . $businessId;
|
||||
$invoiceSettingKey = 'invoice_setting_'.$businessId;
|
||||
$invoice_setting = Option::where('key', $invoiceSettingKey)->first();
|
||||
$product_setting = ProductSetting::where('business_id', auth()->user()->business_id)->first();
|
||||
|
||||
$currencySettingKey = 'currency_setting_' . $businessId;
|
||||
$currencySettingKey = 'currency_setting_'.$businessId;
|
||||
$currency_setting = Option::where('key', $currencySettingKey)->first();
|
||||
|
||||
return view('business::manage-settings.index', compact('invoice_setting', 'product_setting', 'currency_setting'));
|
||||
$invoiceImgaeSettingKey = 'invoice_setting_images';
|
||||
$invoice_setting_image = Option::where('key', $invoiceImgaeSettingKey)->first();
|
||||
|
||||
$themesettingkey = 'theme_setting_'.$businessId;
|
||||
$theme_settings = Option::where('key', $themesettingkey)->first()?->value ?? [];
|
||||
|
||||
return view('business::manage-settings.index', compact('invoice_setting', 'theme_settings', 'product_setting', 'currency_setting', 'invoice_setting_image'));
|
||||
}
|
||||
|
||||
public function updateInvoice(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'invoice_size' => 'required|string|max:100|in:a4,3_inch_80mm',
|
||||
'invoice_size' => 'required|string|max:100|in:a4,3_inch_80mm,standard_a4',
|
||||
]);
|
||||
|
||||
$key = 'invoice_setting_' . auth()->user()->business_id;
|
||||
$key = 'invoice_setting_'.auth()->user()->business_id;
|
||||
|
||||
Option::updateOrCreate(
|
||||
['key' => $key],
|
||||
@@ -45,8 +51,8 @@ public function updateInvoice(Request $request)
|
||||
public function updateProductSetting(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'show_product_price' => 'nullable|boolean',
|
||||
'show_product_code' => 'nullable|boolean',
|
||||
'show_hsn_code' => 'nullable|boolean',
|
||||
'show_product_stock' => 'nullable|boolean',
|
||||
'show_product_sale_price' => 'nullable|boolean',
|
||||
'show_product_dealer_price' => 'nullable|boolean',
|
||||
@@ -94,9 +100,9 @@ public function updateProductSetting(Request $request)
|
||||
]);
|
||||
|
||||
if (
|
||||
!$request->boolean('show_product_type_single') &&
|
||||
!$request->boolean('show_product_type_variant') &&
|
||||
!$request->boolean('show_product_type_combo')
|
||||
! $request->boolean('show_product_type_single') &&
|
||||
! $request->boolean('show_product_type_variant') &&
|
||||
! $request->boolean('show_product_type_combo')
|
||||
) {
|
||||
throw ValidationException::withMessages([
|
||||
'product_type' => ['At least one product type must be selected: Single, Variant or Combo.'],
|
||||
@@ -133,7 +139,7 @@ public function updateProductSetting(Request $request)
|
||||
['modules' => $modules]
|
||||
);
|
||||
|
||||
Cache::forget('product_setting_' . $businessId);
|
||||
Cache::forget('product_setting_'.$businessId);
|
||||
|
||||
return response()->json(__('Product setting updated successfully.'));
|
||||
}
|
||||
@@ -144,7 +150,7 @@ public function updateCurrency(Request $request)
|
||||
'currency' => 'required|string|max:100|in:us,european',
|
||||
]);
|
||||
|
||||
$key = 'currency_setting_' . auth()->user()->business_id;
|
||||
$key = 'currency_setting_'.auth()->user()->business_id;
|
||||
|
||||
Option::updateOrCreate(
|
||||
['key' => $key],
|
||||
@@ -174,13 +180,39 @@ public function updateSerial(Request $request)
|
||||
$modules['show_serial'] = $request->boolean('show_serial') ? '1' : '0';
|
||||
|
||||
$setting->update([
|
||||
'modules' => $modules
|
||||
'modules' => $modules,
|
||||
]);
|
||||
|
||||
Cache::forget('product_setting_' . $businessId);
|
||||
Cache::forget('product_setting_'.$businessId);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Serial setting updated successfully.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateTheme(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'primary_color' => 'nullable|string|max:100',
|
||||
'secondary_color' => 'nullable|string|max:100',
|
||||
'sidebar_color' => 'nullable|string|max:100',
|
||||
'accent_color' => 'nullable|string|max:100',
|
||||
]);
|
||||
|
||||
$businessId = auth()->user()->business_id;
|
||||
|
||||
$setting = Option::updateOrCreate(
|
||||
['key' => 'theme_setting_'.$businessId],
|
||||
['value' => [
|
||||
'primary_color' => $request->primary_color,
|
||||
'secondary_color' => $request->secondary_color,
|
||||
'sidebar_color' => $request->sidebar_color,
|
||||
'accent_color' => $request->accent_color,
|
||||
]]
|
||||
);
|
||||
|
||||
Cache::forget('theme_setting_'.$businessId);
|
||||
|
||||
return response()->json(__('Theme updated successfully.'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user