Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ more enjoyable for attendees and organisers alike.
3. Generate and copy a new application key:

```bash
docker run --rm --entrypoint php -w /app zeropingheroes/lanager:develop artisan key:generate --show
docker run --rm --entrypoint php -w /app zeropingheroes/lanager artisan key:generate --show
```

4. Open the environment configuration file in a text editor:
Expand Down
19 changes: 12 additions & 7 deletions app/Http/Controllers/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ImageController extends Controller
/**
* Uploaded image storage location.
*/
public const string DIRECTORY = 'public/images';
public const string DIRECTORY = 'images';

/**
* Display a listing of the resource.
Expand All @@ -36,7 +36,7 @@ public function index(): ViewContract
$this->authorize('images.view');

// Get all files in image path
$files = collect(Storage::files(self::DIRECTORY));
$files = collect(Storage::disk('public')->files(self::DIRECTORY));

// Only show image files
$images = $files->filter(
Expand Down Expand Up @@ -85,7 +85,7 @@ public function store(Request $httpRequest): RedirectResponse

$newFileName = Str::slug($fileName).'.'.strtolower((string) $extension);

$image->storeAs(self::DIRECTORY, $newFileName);
$image->storeAs(self::DIRECTORY, $newFileName, 'public');
}

Session::flash('success', trans('phrase.images-successfully-uploaded'));
Expand All @@ -103,7 +103,7 @@ public function edit(string $filename): ViewContract
$this->authorize('images.update');

$filePath = self::DIRECTORY.'/'.$filename;
if (! Storage::exists($filePath)) {
if (! Storage::disk('public')->exists($filePath)) {
abort(404);
}

Expand Down Expand Up @@ -132,6 +132,11 @@ public function update(Request $httpRequest, string $filename): RedirectResponse
$newFilenameWithoutExtension = Str::before($httpRequest->input('filename'), '.'.$originalFileExtension);
$newFilePath = self::DIRECTORY.'/'.$newFilenameWithoutExtension.'.'.$originalFileExtension;

// $originalFilePath = Storage::disk('public')->path(self::DIRECTORY.'/'.$filename);
// $originalFileExtension = File::extension($originalFilePath);
// $newFilenameWithoutExtension = Str::before($httpRequest->input('filename'), '.'.$originalFileExtension);
// $newFilePath = self::DIRECTORY.'/'.$newFilenameWithoutExtension.'.'.$originalFileExtension;

$input = [
'original_file_path' => $originalFilePath,
'new_file_path' => $newFilePath,
Expand All @@ -146,7 +151,7 @@ public function update(Request $httpRequest, string $filename): RedirectResponse
return redirect()->back()->withInput();
}

Storage::move($originalFilePath, $newFilePath);
Storage::disk('public')->move($originalFilePath, $newFilePath);

return redirect()
->route('images.index');
Expand All @@ -162,11 +167,11 @@ public function destroy(string $filename): RedirectResponse
$this->authorize('images.delete');

$file = self::DIRECTORY.'/'.$filename;
if (! Storage::exists($file)) {
if (! Storage::disk('public')->exists($file)) {
abort(404);
}

Storage::delete($file);
Storage::disk('public')->delete($file);

Session::flash(
'success',
Expand Down
4 changes: 2 additions & 2 deletions app/Requests/UpdateImageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UpdateImageRequest extends Request
#[\Override]
public function valid(): bool
{
if (! Storage::exists($this->input['original_file_path'])) {
if (! Storage::disk('public')->exists($this->input['original_file_path'])) {
abort(404);
}

Expand All @@ -26,7 +26,7 @@ public function valid(): bool
return $this->setValid(false);
}

if (Storage::exists($this->input['new_file_path'])) {
if (Storage::disk('public')->exists($this->input['new_file_path'])) {
$this->addError(trans('phrase.image-already-exists'));

return $this->setValid(false);
Expand Down
Loading
Loading