Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ysbrandB/portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbrandB committed Jun 26, 2024
2 parents b2ae9d2 + c444e67 commit 797fac1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/Console/Commands/example_code_to_markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class example_code_to_markdown extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
foreach (Item::all() as $item) {
$item->example_code = $this->convertCodeToMarkdown($item->example_code);
Expand All @@ -35,7 +35,7 @@ public function handle()
private function convertCodeToMarkdown(string $code): string
{
return '```
' . $code . '
'.$code.'
```';
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function store(Request $request, int $itemId)
$item = Item::findOrFail($itemId);
$photo = $request->file('photo');

if(!$photo) {
if (! $photo) {
return response()->json(['error' => 'No photo provided'], 400);
}

Expand All @@ -25,15 +25,15 @@ public function store(Request $request, int $itemId)
'path' => $photo->hashName(),
]);

return ['url'=>$photoModel->url, 'id'=>$photoModel->id];
return ['url' => $photoModel->url, 'id' => $photoModel->id];
}

public function destroy(Request $request, int $itemId, int $photoId)
{
$item = Item::findOrFail($itemId);
$photo = Photo::findOrFail($photoId);

if($photo->item_id !== $item->id) {
if ($photo->item_id !== $item->id) {
return response()->json(['error' => 'Photo does not belong to item'], 400);
}

Expand Down
3 changes: 2 additions & 1 deletion app/Models/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ public function item(): BelongsTo
{
return $this->belongsTo(Item::class);
}

public function getUrlAttribute(): string
{
return asset('storage/photos/'.$this->path);
}

public static function boot(): void
protected static function boot(): void
{
parent::boot();
static::deleting(static function (Photo $photo): void {
Expand Down

0 comments on commit 797fac1

Please sign in to comment.