Skip to content

Commit 27a042f

Browse files
authored
Merge pull request #883 from w3bdesign/dev
Fix SingleProduct bug
2 parents 68f4b7e + a7b54b8 commit 27a042f

File tree

11 files changed

+56212
-59785
lines changed

11 files changed

+56212
-59785
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Ecommerce site with Laravel 10, Vue 3 and Stripe.
4545

4646
- Fork or clone the project
4747

48-
- Ensure you have PHP 8.1 or newer installed and setup properly (alternatively use Docker, see <https://laravel.com/docs/9.x/sail>)
48+
- Ensure you have PHP 8.2.4 or newer installed and setup properly (alternatively use Docker, see <https://laravel.com/docs/9.x/sail>)
4949

5050
- Ensure you have access to a PostgreSQL database
5151

@@ -57,7 +57,7 @@ Ecommerce site with Laravel 10, Vue 3 and Stripe.
5757

5858
- Run `npm install` to install the Node dependencies needed by the project. Check out <https://nodejs.org/en/> if necessary
5959

60-
- Run `php artisan:migrate` to setup the Laravel database migrations
60+
- Run `php artisan migrate:install` to setup the Laravel database migrations
6161

6262
- You should create at least one sample product. Although you can use the builtin factory seeders, I prefer to do manual creation for testing purposes.
6363

@@ -68,7 +68,7 @@ Ecommerce site with Laravel 10, Vue 3 and Stripe.
6868
$product->name = 'Example Product';
6969
$product->slug = 'example-product';
7070
$product->description = 'Example product description';
71-
$product->imageUrl = 'url to image';
71+
$product->imageUrl = 'https://placehold.co/400x400';
7272
$product->price = 99;
7373
$product->save();
7474
```

app/Http/Controllers/Api/ProductController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ public function index()
1515
->get();
1616
}
1717

18-
public function show(Product $product)
18+
public function show($slug)
1919
{
20-
$product->load('categories:id,name');
20+
$product = Product::where('slug', $slug)
21+
->with(['categories:id,name'])
22+
->firstOrFail();
2123

2224
return $product;
2325
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"license": "MIT",
1010
"require": {
11-
"php": "8.2.6",
11+
"php": "8.2.4",
1212
"guzzlehttp/guzzle": "7.7.0",
1313
"laravel/cashier": "v14.12.1",
1414
"laravel/framework": "v10.11.0",

0 commit comments

Comments
 (0)