Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshack committed Dec 28, 2023
1 parent 641961a commit c8e747c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/ShotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class ShotController extends Controller
public function index(Request $request)
{
return Inertia::render('Shots/Index', [
'shots' => fn () => $request->user()->shots
'shots' => fn () => $request->user()->shots,
]);
}

public function show(string $id)
{
return Inertia::render('Shots/Show', [
'shot' => fn () => Shot::whereId($id)->firstOrFail()
'shot' => fn () => Shot::whereId($id)->firstOrFail(),
]);
}
}
5 changes: 2 additions & 3 deletions app/Http/Controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers;

use App\Http\Requests\UploadRequest;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;

class UploadController extends Controller
Expand All @@ -15,10 +14,10 @@ public function __invoke(UploadRequest $request)
// UploadedFile::createFromBase($image)->store('uploads');
// }

$path = UploadedFile::createFromBase($request->files->get("images")[0])->storePublicly('uploads');
$path = UploadedFile::createFromBase($request->files->get('images')[0])->storePublicly('uploads');

$shot = $request->user()->shots()->create([
'path' => $path
'path' => $path,
]);

return to_route('shots.show', $shot->getKey());
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Requests/UploadRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class UploadRequest extends FormRequest
public function rules(): array
{
return [
'images' => ['array', 'min:1', 'max:1'],
'images.*' => ['mimes:'. implode(',', $this->allowedTypes)]
'images' => ['array', 'min:1', 'max:1'],
'images.*' => ['mimes:'.implode(',', $this->allowedTypes)],
];
}

public function messages() : array
public function messages(): array
{
return [
'images' => 'You must upload no more than 1 image at a time.',
'images.*' => "You may only upload one of the following types: " . implode(', ', $this->allowedTypes)
'images' => 'You must upload no more than 1 image at a time.',
'images.*' => 'You may only upload one of the following types: '.implode(', ', $this->allowedTypes),
];
}
}
6 changes: 2 additions & 4 deletions app/Models/Shot.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
namespace App\Models;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;

/**
* @property int $id
Expand All @@ -22,7 +20,7 @@ class Shot extends Model
];

protected $appends = [
'url'
'url',
];

protected function url(): Attribute
Expand All @@ -32,7 +30,7 @@ protected function url(): Attribute
);
}

public function user() : BelongsTo
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class User extends Authenticatable
'password' => 'hashed',
];

public function shots() : HasMany
public function shots(): HasMany
{
return $this->hasMany(Shot::class);
}
Expand Down
11 changes: 4 additions & 7 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\ShotController;
use App\Http\Controllers\UploadController;
use App\Models\Shot;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

Expand All @@ -25,11 +22,11 @@
return Inertia::render('Home');
})->name('home');

Route::prefix("shots")
->name("shots.")
->prefix("shots")
Route::prefix('shots')
->name('shots.')
->prefix('shots')
->controller(ShotController::class)
->group(function() {
->group(function () {
Route::get('', 'index')
->middleware(['auth', 'verified'])
->name('index');
Expand Down

0 comments on commit c8e747c

Please sign in to comment.