From e9c666db61160f05372063112df11f15fad38078 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:23:56 +0800 Subject: [PATCH 01/18] Update ProjectController.php --- app/Http/Controllers/ProjectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 95aed4f8..9dd169dc 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -15,7 +15,7 @@ public function store(Request $request) // TASK: change the below line so that $filename would contain only filename // The same filename as the original uploaded file - $filename = '???'; + $filename = $request->file('logo')->getClientOriginalName(); $request->file('logo')->storeAs('logos', $filename); Project::create([ From 59bb0c6f9138906560c092098a05a3643cd96fd9 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:26:39 +0800 Subject: [PATCH 02/18] Update ProjectController.php --- app/Http/Controllers/ProjectController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 9dd169dc..a0e55892 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -4,6 +4,7 @@ use App\Models\Project; use Illuminate\Http\Request; +use Illuminate\Validation\Rules\File; class ProjectController extends Controller { @@ -11,6 +12,7 @@ public function store(Request $request) { $request->validate([ // TASK: Write the validation rule so "logo" file would be MAX 1 megabyte + 'logo'=>File::max(10*1024) ]); // TASK: change the below line so that $filename would contain only filename From 54f6a01974dfd8dffe2b85bb36785b999aa78ba1 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:27:11 +0800 Subject: [PATCH 03/18] Update ProjectController.php --- app/Http/Controllers/ProjectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index a0e55892..6c5ab742 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -12,7 +12,7 @@ public function store(Request $request) { $request->validate([ // TASK: Write the validation rule so "logo" file would be MAX 1 megabyte - 'logo'=>File::max(10*1024) + 'logo'=>File::max(1024) ]); // TASK: change the below line so that $filename would contain only filename From 9ad5b47921c9f3d917ce856f4f9d40e486757a9d Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:29:03 +0800 Subject: [PATCH 04/18] Update ProjectController.php --- app/Http/Controllers/ProjectController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 6c5ab742..ad88ec86 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -12,7 +12,7 @@ public function store(Request $request) { $request->validate([ // TASK: Write the validation rule so "logo" file would be MAX 1 megabyte - 'logo'=>File::max(1024) + 'logo'=>File::image()->max(1024) ]); // TASK: change the below line so that $filename would contain only filename From b74fd7067f6c40759c0aa2f7ba99ef160b4a6283 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:31:32 +0800 Subject: [PATCH 05/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index c330f8aa..6bbfa8e1 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -25,6 +25,7 @@ public function update(Request $request, House $house) $filename = $request->file('photo')->store('houses'); // TASK: Delete the old file from the storage + $house->delete('photo'); $house->update([ 'name' => $request->name, From abd342dffbdc71fe8ba0849bae5ed652a2462f48 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:33:16 +0800 Subject: [PATCH 06/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index 6bbfa8e1..fb030935 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -25,7 +25,7 @@ public function update(Request $request, House $house) $filename = $request->file('photo')->store('houses'); // TASK: Delete the old file from the storage - $house->delete('photo'); + Storage::delete($house->photo); $house->update([ 'name' => $request->name, From 6a5e631cd255ccaa47667af4cb6d3b14e91bc19d Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:37:29 +0800 Subject: [PATCH 07/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index fb030935..8191e495 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -39,5 +39,6 @@ public function download(House $house) { // TASK: Return the $house->photo file from "storage/app/houses" folder // for download in browser + return Storage::download(storage_path($house->photo)); } } From 1af48c430e9fbc5260b270c4f98fa212d0e0b7c9 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:40:32 +0800 Subject: [PATCH 08/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index 8191e495..f0f40f81 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -39,6 +39,6 @@ public function download(House $house) { // TASK: Return the $house->photo file from "storage/app/houses" folder // for download in browser - return Storage::download(storage_path($house->photo)); + return Storage::download(storage_path('app/houses/'.$house->photo)); } } From d9035c8838cf1c4fca4f753b1046619db8a25b5a Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:41:38 +0800 Subject: [PATCH 09/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index f0f40f81..8790eddb 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -39,6 +39,6 @@ public function download(House $house) { // TASK: Return the $house->photo file from "storage/app/houses" folder // for download in browser - return Storage::download(storage_path('app/houses/'.$house->photo)); + return Storage::download(storage_path('app/'.$house->photo)); } } From 49d02d0bd189a21ed1e6e44a533e450189f23d2c Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:57:28 +0800 Subject: [PATCH 10/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index 8790eddb..8191e495 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -39,6 +39,6 @@ public function download(House $house) { // TASK: Return the $house->photo file from "storage/app/houses" folder // for download in browser - return Storage::download(storage_path('app/'.$house->photo)); + return Storage::download(storage_path($house->photo)); } } From fe22387adc8b0a16a264a47802015d341873980d Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 07:59:01 +0800 Subject: [PATCH 11/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index 8191e495..d1887193 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -39,6 +39,6 @@ public function download(House $house) { // TASK: Return the $house->photo file from "storage/app/houses" folder // for download in browser - return Storage::download(storage_path($house->photo)); + return Storage::download(asset('storage/'.$request->photo)); } } From 255e4e205419620e20b90d33f7b6572e2749d5ed Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:00:41 +0800 Subject: [PATCH 12/18] Update HouseController.php --- app/Http/Controllers/HouseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index d1887193..ba87351b 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -39,6 +39,6 @@ public function download(House $house) { // TASK: Return the $house->photo file from "storage/app/houses" folder // for download in browser - return Storage::download(asset('storage/'.$request->photo)); + return Storage::download($house->photo); } } From 004c61a45c054f490ee43c02624e2018beca270e Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:04:02 +0800 Subject: [PATCH 13/18] Update OfficeController.php --- app/Http/Controllers/OfficeController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/OfficeController.php b/app/Http/Controllers/OfficeController.php index fae443fa..ab50a7ec 100644 --- a/app/Http/Controllers/OfficeController.php +++ b/app/Http/Controllers/OfficeController.php @@ -13,10 +13,11 @@ public function store(Request $request) // TASK: Upload the file "photo" so it would be written as // storage/app/public/offices/[original_filename] + Office::create([ 'name' => $request->name, - 'photo' => $filename, + 'photo' => $request->file('photo')->storeAs('offices',$filename,'public'), ]); return 'Success'; From 97ec08da94e36376953942591350cf8663674d52 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:09:48 +0800 Subject: [PATCH 14/18] Update OfficeController.php --- app/Http/Controllers/OfficeController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/OfficeController.php b/app/Http/Controllers/OfficeController.php index ab50a7ec..965946c8 100644 --- a/app/Http/Controllers/OfficeController.php +++ b/app/Http/Controllers/OfficeController.php @@ -13,11 +13,11 @@ public function store(Request $request) // TASK: Upload the file "photo" so it would be written as // storage/app/public/offices/[original_filename] - + $request->file('photo')->storeAs('offices',$filename,'public'); Office::create([ 'name' => $request->name, - 'photo' => $request->file('photo')->storeAs('offices',$filename,'public'), + ]); return 'Success'; From b04ab1ecb48c75b7ced323a995f186be37af3016 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:14:15 +0800 Subject: [PATCH 15/18] Update OfficeController.php --- app/Http/Controllers/OfficeController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/OfficeController.php b/app/Http/Controllers/OfficeController.php index 965946c8..56052180 100644 --- a/app/Http/Controllers/OfficeController.php +++ b/app/Http/Controllers/OfficeController.php @@ -13,11 +13,11 @@ public function store(Request $request) // TASK: Upload the file "photo" so it would be written as // storage/app/public/offices/[original_filename] - $request->file('photo')->storeAs('offices',$filename,'public'); + $path=$request->file('photo')->storeAs('offices',$filename,'public'); Office::create([ 'name' => $request->name, - + 'photo'=>$path ]); return 'Success'; From f42f46fe2509bd01ce135f65b57ede536e000198 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:20:39 +0800 Subject: [PATCH 16/18] Update OfficeController.php From 8e9821a8d3506b402a9faec57bac46ada539427b Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:27:18 +0800 Subject: [PATCH 17/18] Update OfficeController.php --- app/Http/Controllers/OfficeController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/OfficeController.php b/app/Http/Controllers/OfficeController.php index 56052180..fc7c9f3f 100644 --- a/app/Http/Controllers/OfficeController.php +++ b/app/Http/Controllers/OfficeController.php @@ -13,11 +13,11 @@ public function store(Request $request) // TASK: Upload the file "photo" so it would be written as // storage/app/public/offices/[original_filename] - $path=$request->file('photo')->storeAs('offices',$filename,'public'); + Office::create([ 'name' => $request->name, - 'photo'=>$path + 'photo'=>$request->file('photo')->storePubliclyAs('offices',$filename,'public') ]); return 'Success'; From a70b435b281eb1ea12c3f7cae71871c8a114df55 Mon Sep 17 00:00:00 2001 From: OhmygoodR <109280933+OhmygoodR@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:28:11 +0800 Subject: [PATCH 18/18] Update OfficeController.php --- app/Http/Controllers/OfficeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/OfficeController.php b/app/Http/Controllers/OfficeController.php index fc7c9f3f..c3d3c6be 100644 --- a/app/Http/Controllers/OfficeController.php +++ b/app/Http/Controllers/OfficeController.php @@ -17,7 +17,7 @@ public function store(Request $request) Office::create([ 'name' => $request->name, - 'photo'=>$request->file('photo')->storePubliclyAs('offices',$filename,'public') + 'photo'=>$request->file('photo')->storeAs('offices',$filename,'public') ]); return 'Success';