Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finish all #195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/Http/Controllers/CompanyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +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')->first()->getFullUrl();
return view('companies.show', compact('company', 'photo'));
}

}
63 changes: 32 additions & 31 deletions app/Http/Controllers/HouseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,36 @@

class HouseController extends Controller
{
public function store(Request $request)
{
$filename = $request->file('photo')->store('houses');

House::create([
'name' => $request->name,
'photo' => $filename,
]);

return 'Success';
}

public function update(Request $request, House $house)
{
$filename = $request->file('photo')->store('houses');

// TASK: Delete the old file from the storage

$house->update([
'name' => $request->name,
'photo' => $filename,
]);

return 'Success';
}

public function download(House $house)
{
// TASK: Return the $house->photo file from "storage/app/houses" folder
// for download in browser
}
public function store(Request $request)
{
$filename = $request->file('photo')->store('houses');

House::create([
'name' => $request->name,
'photo' => $filename,
]);

return 'Success';
}

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,
'photo' => $filename,
]);

return 'Success';
}

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);
}
}
3 changes: 1 addition & 2 deletions 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 All @@ -26,5 +26,4 @@ public function show(Office $office)
{
return view('offices.show', compact('office'));
}

}
6 changes: 4 additions & 2 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ public function store(Request $request)
{
$request->validate([
// TASK: Write the validation rule so "logo" file would be MAX 1 megabyte
'logo' => ['file', 'max:1024']
]);

// 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([
'name' => $request->name,
'logo' => $filename,
]);

return 'Success';
}
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/ShopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function store(Request $request)
// 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';
}
}
Loading