Skip to main content
added 467 characters in body
Source Link

In the PromotionService class, inside the claim() method, you are throwing a RuntimeException, not sure why... While the RuntimeException works, a custom exception provides much clearer and more specific context about why the claim failed, which is beneficial for code maintainability, debugging, and handling the error in the calling code. Use a custom exception like

throw new PromotionAlreadyClaimedException('This promotion has already been claimed');

Lastly, I noticed that you aren't using a 201 status code for the createPromotion() method for the BoPromotionContrller, for some reason when you do in other Controllers

Lastly, I noticed that you aren't using a 201 status code for the createPromotion() method for the BoPromotionContrller, for some reason when you do in other Controllers

In the PromotionService class, inside the claim() method, you are throwing a RuntimeException, not sure why... While the RuntimeException works, a custom exception provides much clearer and more specific context about why the claim failed, which is beneficial for code maintainability, debugging, and handling the error in the calling code. Use a custom exception like

throw new PromotionAlreadyClaimedException('This promotion has already been claimed');

Lastly, I noticed that you aren't using a 201 status code for the createPromotion() method for the BoPromotionContrller, for some reason when you do in other Controllers

added 12 characters in body
Source Link

Another thing is to look into "return type declarations" in Laravel. I think you might already know about return type declarations since you use them in your PromotionService class but inside your Controller methods you don't. For example, in the BoPromotionController you aren't using the JsonResponse return type declaration, it should look like this for each Controller method

public function createPromotion(CreatePromotionRequest $request, PromotionService $promotionService): JsonResponse {...}

public function deletePromotion(CreatePromotionRequest $request, PromotionService $promotionService): JsonResponse {...}

Make sure to import use Illuminate\Http\JsonResponse;

etc...

Lastly, I noticed that you aren't using a 201 status code for the createPromotion() method for the BoPromotionContrller, for some reason when you do in other Controllers

Lastly, I noticed that you aren't using a 201 status code for the createPromotion() method for the BoPromotionContrller, for some reason when you do in other Controllers

Another thing is to look into "return type declarations" in Laravel. I think you might already know about return type declarations since you use them in your PromotionService class but inside your Controller methods you don't. For example, in the BoPromotionController you aren't using the JsonResponse return type declaration, it should look like this for each Controller method

public function createPromotion(CreatePromotionRequest $request, PromotionService $promotionService): JsonResponse {...}

public function deletePromotion(CreatePromotionRequest $request, PromotionService $promotionService): JsonResponse {...}

Make sure to import use Illuminate\Http\JsonResponse;

etc...

Lastly, I noticed that you aren't using a 201 status code for the createPromotion() method for the BoPromotionContrller, for some reason when you do in other Controllers

added 12 characters in body
Source Link
public function delete(PromotionService $promotionService, string $id){
    $promotionService->delete(...$id);
public function delete(PromotionService $promotionService){
    $promotionService->delete(...);
public function delete(PromotionService $promotionService, string $id){
    $promotionService->delete($id);
added 938 characters in body
Source Link
Loading
added 3 characters in body
Source Link
Loading
added 1 character in body
Source Link
Loading
deleted 10 characters in body
Source Link
toolic
  • 16.4k
  • 6
  • 29
  • 221
Loading
Source Link
Loading