Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update composer.json #131

Merged
merged 2 commits into from
Feb 15, 2024
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.10",
"nunomaduro/collision": "^5.5",
"nunomaduro/larastan": "^0.7.6",
"orchestra/testbench": "^6.0|^7.0",
"nunomaduro/collision": ">=5.5",
"nunomaduro/larastan": ">=0.7.6",
"orchestra/testbench": ">=7.0",
"phpunit/phpunit": "^9.0",
"escolalms/courses": "^0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/ProductAdminApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public function delete(ProductDeleteRequest $request): JsonResponse

public function attach(ProductAttachRequest $request): JsonResponse
{
$this->productService->attachProductToUser($request->getProduct(), $request->getUser());
$this->productService->attachProductToUser($request->getProduct(), $request->getCartUser());
return $this->sendSuccess(__('Product attached to user'));
}

public function detach(ProductDetachRequest $request): JsonResponse
{
$this->productService->detachProductFromUser($request->getProduct(), $request->getUser());
$this->productService->detachProductFromUser($request->getProduct(), $request->getCartUser());
return $this->sendSuccess(__('Product detached from user'));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/ProductableAdminApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public function index(ProductableListRequest $request): JsonResponse
public function attach(ProductableAttachRequest $request): JsonResponse
{
$productable = $this->productService->findProductable($request->getProductableType(), $request->getProductableId());
$user = $request->getUser();
$user = $request->getCartUser();
$this->productService->attachProductableToUser($productable, $user);
return $this->sendSuccess(__('Productable attached to user'));
}

public function detach(ProductableDetachRequest $request): JsonResponse
{
$productable = $this->productService->findProductable($request->getProductableType(), $request->getProductableId());
$user = $request->getUser();
$user = $request->getCartUser();
if (!$this->productService->canDetachProductableFromUser($productable, $user)) {
return $this->sendError(__('Unable to detach productable that was bought by User'), 403);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/Admin/ProductAttachRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getProduct(): Product
return Product::findOrFail($this->getProductId());
}

public function getUser(): User
public function getCartUser(): User
{
return User::findOrFail($this->input('user_id'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/Admin/ProductDetachRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getProduct(): Product
return Product::findOrFail($this->getProductId());
}

public function getUser(): User
public function getCartUser(): User
{
return User::findOrFail($this->input('user_id'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/Admin/ProductableAttachRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getProductableType(): string
return $this->validated()['productable_type'];
}

public function getUser(): User
public function getCartUser(): User
{
return User::findOrFail($this->input('user_id'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/Admin/ProductableDetachRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getProductableType(): string
return $this->validated()['productable_type'];
}

public function getUser(): User
public function getCartUser(): User
{
return User::findOrFail($this->input('user_id'));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/API/AdminProductApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public function test_create_product_min_price()
$this->response->assertJson(
fn (AssertableJson $json) =>
$json
->where('message', 'The given data was invalid.')
->where('message', 'Field price must be greater than or equal to 10. (and 1 more error)')
->where('errors', [
'price' => ['Field price must be greater than or equal to 10.'],
'price_old' => ['Field price old must be greater than or equal to 10.'],
Expand Down Expand Up @@ -302,7 +302,7 @@ public function test_update_product_min_price()
$this->response->assertJson(
fn (AssertableJson $json) =>
$json
->where('message', 'The given data was invalid.')
->where('message', 'Field price must be greater than or equal to 10. (and 1 more error)')
->where('errors', [
'price' => ['Field price must be greater than or equal to 10.'],
'price_old' => ['Field price old must be greater than or equal to 10.'],
Expand Down
2 changes: 1 addition & 1 deletion tests/API/CartApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function test_added_more_than_limit_per_user()
$this->response->assertUnprocessable();
$this->response->assertJson(
fn (AssertableJson $json) =>
$json->where('message', 'The given data was invalid.')
$json->where('message', 'The quantity must not be greater than 1.')
->where('errors.quantity', ['The quantity must not be greater than 1.'])
->etc()
);
Expand Down
Loading