From 2145fdeaa8b5523d594a1a0a1d4498849c55c17b Mon Sep 17 00:00:00 2001 From: Imtyaz Ahmed <54882826+imtyaz-17@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:21:02 +0600 Subject: [PATCH 1/8] T1 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 d802956f051f40cec0076e7925fbb9228a1bb9ca Mon Sep 17 00:00:00 2001 From: Imtyaz Ahmed <54882826+imtyaz-17@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:23:03 +0600 Subject: [PATCH 2/8] T2 Update ProjectController.php --- app/Http/Controllers/ProjectController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 9dd169dc..65778dd8 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -11,6 +11,7 @@ public function store(Request $request) { $request->validate([ // TASK: Write the validation rule so "logo" file would be MAX 1 megabyte + 'logo' => 'required|file|max:1024', ]); // TASK: change the below line so that $filename would contain only filename From 274da9d2c493f15e251b3e77cb6b0f40527b64fa Mon Sep 17 00:00:00 2001 From: Imtyaz Ahmed <54882826+imtyaz-17@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:25:46 +0600 Subject: [PATCH 3/8] T3 Update HouseController.php --- app/Http/Controllers/HouseController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index c330f8aa..afd7e5fa 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -25,6 +25,9 @@ public function update(Request $request, House $house) $filename = $request->file('photo')->store('houses'); // TASK: Delete the old file from the storage + if ($house->photo) { + Storage::delete($house->photo); + } $house->update([ 'name' => $request->name, From 348f390bfe8116a9c0fca3f654ef52dd3c32940d Mon Sep 17 00:00:00 2001 From: Imtyaz Ahmed <54882826+imtyaz-17@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:27:38 +0600 Subject: [PATCH 4/8] T4 Update HouseController.php --- app/Http/Controllers/HouseController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index afd7e5fa..a6aaa4b4 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -1,4 +1,4 @@ -photo file from "storage/app/houses" folder // for download in browser + return Storage::download($house->photo); } } From daaf0c9ba83b8c56e9bf5b5c98eebed8659f0459 Mon Sep 17 00:00:00 2001 From: Imtyaz Ahmed <54882826+imtyaz-17@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:30:16 +0600 Subject: [PATCH 5/8] T4 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 a6aaa4b4..3e95c4b5 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -1,4 +1,4 @@ -f Date: Mon, 8 Jul 2024 10:41:17 +0600 Subject: [PATCH 6/8] T5 Update OfficeController.php --- 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..f8514d28 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('public/offices', $filename); Office::create([ 'name' => $request->name, From b68eb31e86817fdc501a2c0485f274444ed51317 Mon Sep 17 00:00:00 2001 From: Imtyaz Ahmed <54882826+imtyaz-17@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:49:12 +0600 Subject: [PATCH 7/8] T6 Update ShopController.php --- app/Http/Controllers/ShopController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ShopController.php b/app/Http/Controllers/ShopController.php index b2c485a3..bd5519e8 100644 --- a/app/Http/Controllers/ShopController.php +++ b/app/Http/Controllers/ShopController.php @@ -15,7 +15,12 @@ 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 - + $imagePath = storage_path('app/shops/' . $filename); + $resizedImagePath = storage_path('app/shops/resized-' . $filename); + Image::make($imagePath) + ->resize(500, 500) + ->save($resizedImagePath); + return 'Success'; } } From 49827a01a341a25ea20d01136ddc56af8ee3af65 Mon Sep 17 00:00:00 2001 From: Imtyaz Ahmed <54882826+imtyaz-17@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:52:53 +0600 Subject: [PATCH 8/8] T7 Update CompanyController.php --- 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')); }