diff --git a/app/Http/Controllers/ProductGroupController.php b/app/Http/Controllers/ProductGroupController.php new file mode 100644 index 0000000..93f3d41 --- /dev/null +++ b/app/Http/Controllers/ProductGroupController.php @@ -0,0 +1,59 @@ +validate([ + 'code' => 'required|unique:product_groups,code|regex:/^\d{3}$/', + 'name' => 'required|max:20|string|regex:/^[\w\d\s]*$/u' + ]); + + Models\ProductGroup::create($validatedData); + + return redirect()->route('product-groups.index')->with('success', 'Product group created successfully.'); + } + + public function edit(Models\ProductGroup $productGroup) + { + return view('productGroups.edit', compact('productGroup')); + } + + public function update(Request $request, Models\ProductGroup $productGroup) + { + // TODO validate request + $validatedData = $request->validate([ + 'code' => 'required|unique:product_groups,code,'.$productGroup->id.',|regex:/^\d{3}$/', + 'name' => 'required|max:20|string|regex:/^[\w\d\s]*$/u' + ]); + + $productGroup->update($validatedData); + + return redirect()->route('product-groups.index')->with('success', 'Product group updated successfully.'); + } + + public function destroy(Models\ProductGroup $productGroup) + { + $productGroup->delete(); + + return redirect()->route('product-groups.index')->with('success', 'Product group deleted successfully.'); + } + +} diff --git a/app/Models/ProductGroup.php b/app/Models/ProductGroup.php index 0f7ddf0..0b5543b 100644 --- a/app/Models/ProductGroup.php +++ b/app/Models/ProductGroup.php @@ -13,6 +13,8 @@ class ProductGroup extends Model 'sellId', ]; + public $timestamps = false; + // Define relationships with other models (e.g., Subject) public function buySubject() diff --git a/resources/views/components/app-layout.blade.php b/resources/views/components/app-layout.blade.php index 97e7417..398348f 100644 --- a/resources/views/components/app-layout.blade.php +++ b/resources/views/components/app-layout.blade.php @@ -8,7 +8,7 @@ -
+
{{ $slot }}
diff --git a/resources/views/components/header.blade.php b/resources/views/components/header.blade.php index f724c11..9bb4d4e 100644 --- a/resources/views/components/header.blade.php +++ b/resources/views/components/header.blade.php @@ -9,6 +9,7 @@
  • Subjects
  • Transactions
  • Products
  • +
  • Product Groups
  • Customers
  • Customer Groups
  • Bank Accounts
  • diff --git a/resources/views/daisyui.blade.php b/resources/views/daisyui.blade.php new file mode 100644 index 0000000..dba73e7 --- /dev/null +++ b/resources/views/daisyui.blade.php @@ -0,0 +1 @@ +
    \ No newline at end of file diff --git a/resources/views/productGroups/create.blade.php b/resources/views/productGroups/create.blade.php new file mode 100644 index 0000000..1944aba --- /dev/null +++ b/resources/views/productGroups/create.blade.php @@ -0,0 +1,21 @@ + + +

    + {{ __('Create Product Group') }} +

    +
    + +
    +
    + @csrf +
    +

    {{ __('Add product group') }}

    + + @include('productGroups.form') +
    + +
    +
    +
    +
    +
    diff --git a/resources/views/productGroups/edit.blade.php b/resources/views/productGroups/edit.blade.php new file mode 100644 index 0000000..62448e9 --- /dev/null +++ b/resources/views/productGroups/edit.blade.php @@ -0,0 +1,22 @@ + + +

    + {{ __('Edit Product Groups') }} +

    +
    + +
    +
    + @method('PUT') + @csrf +
    +

    {{ __('Edit product group') }}

    + + @include('productGroups.form') +
    + +
    +
    +
    +
    +
    diff --git a/resources/views/productGroups/form.blade.php b/resources/views/productGroups/form.blade.php new file mode 100644 index 0000000..aca3a43 --- /dev/null +++ b/resources/views/productGroups/form.blade.php @@ -0,0 +1,15 @@ +
    +
    + +
    + +
    + +
    +
    diff --git a/resources/views/productGroups/index.blade.php b/resources/views/productGroups/index.blade.php new file mode 100644 index 0000000..5607546 --- /dev/null +++ b/resources/views/productGroups/index.blade.php @@ -0,0 +1,44 @@ + + +

    + {{ __('Products Group') }} +

    +
    + +
    +
    + + + + + + + + + + + + + @foreach ($productGroups as $productGroup) + + + + + + @endforeach + +
    {{ __('Account code') }}{{ __('Name') }}{{ __('Action') }}
    {{ $productGroup->code }}{{ $productGroup->name }} + Edit +
    + @csrf + @method('DELETE') + +
    +
    +
    +
    +
    diff --git a/routes/web.php b/routes/web.php index 41cacfe..8b483f3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,6 +21,7 @@ Route::resource('subjects', Controllers\SubjectController::class); Route::resource('transactions', Controllers\TransactionController::class); Route::resource('products', Controllers\ProductController::class); +Route::resource('product-groups', Controllers\ProductGroupController::class); Route::resource('customers', Controllers\CustomerController::class); Route::resource('customer-groups', Controllers\CustomerGroupController::class); Route::resource('bank-accounts', Controllers\BankAccountController::class);