From 80b86d3f50e6ee4b31e899fe3d5adf52debdf001 Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Wed, 7 May 2025 16:49:48 +0200 Subject: [PATCH 1/5] task 1 and 2 --- app/Http/Controllers/ProjectController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 95aed4f8..1b407e20 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -11,11 +11,12 @@ public function store(Request $request) { $request->validate([ // TASK: Write the validation rule so "logo" file would be MAX 1 megabyte + 'logo' => ['max:1000'] ]); // 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 9c7f56ec76fa6e99fff69c3959422e6c0a44f1dd Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Wed, 7 May 2025 16:51:43 +0200 Subject: [PATCH 2/5] task 3 and 4 --- app/Http/Controllers/HouseController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index c330f8aa..ba87351b 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 + Storage::delete($house->photo); $house->update([ 'name' => $request->name, @@ -38,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($house->photo); } } From cc793614fd73178244b34e40fcd8468eb4f78c08 Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Wed, 7 May 2025 16:53:34 +0200 Subject: [PATCH 3/5] task 5 --- app/Http/Controllers/OfficeController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/OfficeController.php b/app/Http/Controllers/OfficeController.php index fae443fa..4f251f33 100644 --- a/app/Http/Controllers/OfficeController.php +++ b/app/Http/Controllers/OfficeController.php @@ -13,6 +13,7 @@ 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, ['disk' => 'public']); Office::create([ 'name' => $request->name, From 9d2037876ca04bb185923abbffb670dba2ee00bc Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Wed, 7 May 2025 16:54:46 +0200 Subject: [PATCH 4/5] task 6 --- app/Http/Controllers/ShopController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/ShopController.php b/app/Http/Controllers/ShopController.php index b2c485a3..5df39576 100644 --- a/app/Http/Controllers/ShopController.php +++ b/app/Http/Controllers/ShopController.php @@ -15,6 +15,7 @@ public function store(Request $request) // TASK: resize the uploaded image from /storage/app/shops/$filename // to size of 500x500 and store it as /storage/app/shops/resized-$filename // Use intervention/image package, it's already pre-installed for you + Image::make(storage_path('app/shops/' . $filename))->resize(500, 500)->save(storage_path('app/shops/resized-' . $filename)); return 'Success'; } From f6237dc3548bbf9276c695d34aa78b09e30c0620 Mon Sep 17 00:00:00 2001 From: klaudia tamburi Date: Wed, 7 May 2025 16:58:35 +0200 Subject: [PATCH 5/5] task 7 --- app/Http/Controllers/CompanyController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 12fcb81d..3125deaf 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -20,7 +20,7 @@ public function store(Request $request) public function show(Company $company) { // TASK: retrieve the full URL to the uploaded photo file, using Spatie Media Library - $photo = '???'; + $photo = $company->getFirstMediaUrl('companies'); return view('companies.show', compact('company', 'photo')); }