From 3dc8bb2965f56708232ff3b8736d1af74733cfff Mon Sep 17 00:00:00 2001 From: Rasni Nathees Date: Wed, 31 Jul 2024 01:12:30 +0530 Subject: [PATCH 1/2] Fix for - unable edit customer --- app/Http/Controllers/CustomerController.php | 2 +- app/Http/Requests/StoreCustomerRequest.php | 11 ++ composer.json | 1 + composer.lock | 154 +++++++++++++++++++- public/hot | 1 + resources/views/customer/edit.blade.php | 18 ++- 6 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 public/hot diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 95459c4..e16bb50 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -47,7 +47,7 @@ public function edit(Customer $customer) public function update(Customer $customer, StoreCustomerRequest $request) { - $customer->update($request->all()); + $customer->update($request->except(['avatar'])); return redirect('customer')->with('success', 'customer '.$customer->name.' udpated!'); } diff --git a/app/Http/Requests/StoreCustomerRequest.php b/app/Http/Requests/StoreCustomerRequest.php index 8033a30..51c9828 100644 --- a/app/Http/Requests/StoreCustomerRequest.php +++ b/app/Http/Requests/StoreCustomerRequest.php @@ -23,6 +23,17 @@ public function authorize() */ public function rules() { + + if($this->isMethod('put')){ + return [ + 'name' => 'required', + 'address' => 'required|max:255', + 'job' => 'required', + 'birthdate' => 'required|date', + 'gender' => 'required|in:Male,Female', + 'avatar' => 'mimes:png,jpg', + ]; + } return [ 'name' => 'required', 'address' => 'required|max:255', diff --git a/composer.json b/composer.json index 5fa5845..a96fb4c 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "pusher/pusher-php-server": "^7.2" }, "require-dev": { + "barryvdh/laravel-debugbar": "^3.13", "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.15", "laravel/sail": "^1.0.1", diff --git a/composer.lock b/composer.lock index f7c3452..145a992 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "11604c3db15dbf7d1988aa7f3d79d813", + "content-hash": "79646ae26439512388301b85d0c275af", "packages": [ { "name": "brick/math", @@ -6797,6 +6797,90 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.13.5", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "92d86be45ee54edff735e46856f64f14b6a8bb07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/92d86be45ee54edff735e46856f64f14b6a8bb07", + "reference": "92d86be45ee54edff735e46856f64f14b6a8bb07", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10|^11", + "illuminate/session": "^9|^10|^11", + "illuminate/support": "^9|^10|^11", + "maximebf/debugbar": "~1.22.0", + "php": "^8.0", + "symfony/finder": "^6|^7" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^5|^6|^7|^8|^9", + "phpunit/phpunit": "^9.6|^10.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.13-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + } + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.13.5" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2024-04-12T11:20:37+00:00" + }, { "name": "fakerphp/faker", "version": "v1.23.1", @@ -7111,6 +7195,74 @@ }, "time": "2024-03-20T20:09:31+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.22.3", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96", + "reference": "7aa9a27a0b1158ed5ad4e7175e8d3aee9a818b96", + "shasum": "" + }, + "require": { + "php": "^7.2|^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6|^7" + }, + "require-dev": { + "dbrekelmans/bdi": "^1", + "phpunit/phpunit": "^8|^9", + "symfony/panther": "^1|^2.1", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.22-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "support": { + "issues": "https://github.com/maximebf/php-debugbar/issues", + "source": "https://github.com/maximebf/php-debugbar/tree/v1.22.3" + }, + "time": "2024-04-03T19:39:26+00:00" + }, { "name": "mockery/mockery", "version": "1.6.11", diff --git a/public/hot b/public/hot new file mode 100644 index 0000000..b727929 --- /dev/null +++ b/public/hot @@ -0,0 +1 @@ +http://127.0.0.1:5173 \ No newline at end of file diff --git a/resources/views/customer/edit.blade.php b/resources/views/customer/edit.blade.php index 80d2a18..2860dff 100644 --- a/resources/views/customer/edit.blade.php +++ b/resources/views/customer/edit.blade.php @@ -9,7 +9,7 @@
+ action="{{ route('customer.update', ['customer' => $customer->id]) }}" enctype="multipart/form-data"> @method('PUT') @csrf
@@ -42,6 +42,20 @@
@enderror
+
+ + + @error('gender') +
+ {{ $message }} +
+ @enderror +
- + @error('avatar')
{{ $message }} From 09e3cf02908cf20567d17d150c460cf5ec6a2810 Mon Sep 17 00:00:00 2001 From: Rasni Nathees Date: Wed, 31 Jul 2024 01:14:29 +0530 Subject: [PATCH 2/2] undo Customer controller file --- app/Http/Controllers/CustomerController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index e16bb50..95459c4 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -47,7 +47,7 @@ public function edit(Customer $customer) public function update(Customer $customer, StoreCustomerRequest $request) { - $customer->update($request->except(['avatar'])); + $customer->update($request->all()); return redirect('customer')->with('success', 'customer '.$customer->name.' udpated!'); }