Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedGimmiy committed Mar 18, 2024
1 parent 5b954e6 commit 9070b32
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/CompanyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->getMedia('companies')[0]->getFullUrl();

return view('companies.show', compact('company', 'photo'));
}
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/HouseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/OfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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, 'public');
Office::create([
'name' => $request->name,
'photo' => $filename,
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ class ProjectController extends Controller
public function store(Request $request)
{
$request->validate([
'logo' => 'max:1024'
// TASK: Write the validation rule so "logo" file would be MAX 1 megabyte
]);

// 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([
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ShopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +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';
}
}
3 changes: 2 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -23,6 +24,6 @@ public function register()
*/
public function boot()
{
//
Schema::defaultStringLength(191);
}
}

0 comments on commit 9070b32

Please sign in to comment.