Skip to content

Commit

Permalink
wip file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SethSharp committed Feb 5, 2024
1 parent d8bd18b commit 278b529
Show file tree
Hide file tree
Showing 11 changed files with 458 additions and 119 deletions.
11 changes: 5 additions & 6 deletions app/Domain/File/Actions/StoreFileAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ public function __invoke(UploadedFile $file): File

$dir = app()->environment('local')
? 'testing/'
: 'production';
: 'production/';

$path = $file->hashName(path: $dir . 'categories');

Storage::disk(config('filesystems.default'))
->put($path, $img, 'public');
Storage::disk('s3')
->put($path, $img, 'public-read');

return File::create([
'path' => app()->environment('local')
? $path
: Storage::url($path)
'blog_id' => 1,
'path' => Storage::disk('s3')->url($path),
]);
}
}
1 change: 1 addition & 0 deletions app/Domain/File/Models/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

class File extends Model
{
protected $guarded = [];
}
16 changes: 16 additions & 0 deletions app/Http/Controllers/Dashboard/Files/CreateFileController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Controllers\Dashboard\Files;

use App\Http\Controllers\Controller;
use App\Domain\File\Actions\StoreFileAction;
use Inertia\Inertia;
use Inertia\Response;

class CreateFileController extends Controller
{
public function __invoke(StoreFileAction $action): Response
{
return Inertia::render('Dashboard/Files/Create');
}
}
5 changes: 4 additions & 1 deletion app/Http/Controllers/Dashboard/Files/StoreFileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use App\Http\Controllers\Controller;
use App\Domain\File\Actions\StoreFileAction;
use App\Http\Requests\Dashboard\Files\StoreFileRequest;

class StoreFileController extends Controller
{
public function __invoke(StoreFileAction $action): array
public function __invoke(StoreFileRequest $request, StoreFileAction $action): array
{
$file = $action($request->file('file'));
dd($file);
return [
'url' => 'some-url-to-the-image'
];
Expand Down
22 changes: 0 additions & 22 deletions app/Http/Controllers/Dashboard/StoreFileController.php

This file was deleted.

19 changes: 19 additions & 0 deletions app/Http/Requests/Dashboard/Files/StoreFileRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Requests\Dashboard\Files;

class StoreFileRequest extends \Illuminate\Foundation\Http\FormRequest
{
public function authorize()
{
return true;
}

public function rules()
{
return [
'file' => 'required|image|max:2000',
'description' => ['min:5']
];
}
}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
"license": "MIT",
"require": {
"php": "^8.1",
"aws/aws-sdk-php": "^3.298",
"codinglabsau/laravel-roles": "^2.4",
"codinglabsau/php-styles": "dev-main",
"guzzlehttp/guzzle": "^7.2",
"inertiajs/inertia-laravel": "^0.6.8",
"intervention/image": "^3.3",
"intervention/image": "^2.7",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.7",
"league/flysystem-aws-s3-v3": "^3.0",
"livewire/livewire": "^2.12",
"tightenco/ziggy": "^1.0",
"aws/aws-sdk-php": "^3.288",
"league/flysystem-aws-s3-v3": "^3.0"
"tightenco/ziggy": "^1.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
Expand Down
Loading

0 comments on commit 278b529

Please sign in to comment.