Skip to content

Commit 8c61db7

Browse files
authored
Merge pull request #284 from webreinvent/feature/updated-api-responses
feature->develop | Updated API Responses
2 parents 4e980f7 + 09afb6a commit 8c61db7

File tree

13 files changed

+1265
-762
lines changed

13 files changed

+1265
-762
lines changed

content/6.laravel/4.performance.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Performance
3+
---
4+
5+
## Laravel Performance: Reduce Memory Usage & Optimize Queries
6+
7+
Improving performance in Laravel goes beyond just faster queries — it also includes reducing memory usage. One major area of optimization is how we load and process data.
8+
9+
Using **Eloquent collections** instead of traditional `foreach` loops allows Laravel to leverage more efficient internal methods, resulting in lower memory consumption and cleaner code. Additionally, properly **eager-loading relationships** with the `with()` method helps prevent the **N+1 query problem**, which can severely degrade performance.
10+
11+
This video highlights the best practices for:
12+
13+
- Reducing memory usage in Laravel apps
14+
- Using collections over `foreach` loops
15+
- Eager loading relationships efficiently
16+
- Writing cleaner, more performant Eloquent queries
17+
18+
🎥 **Watch Video**:
19+
20+
<figure class="video_container">
21+
<iframe width="560" height="315" src="https://www.youtube.com/embed/-W9Syinl__0?si=fOhlDEH0zCnfJQvw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="true" style="width: 100%; aspect-ratio: 16/9;"></iframe>
22+
</figure>
23+
24+
25+
> _Avoid N+1 queries and high memory usage by using collections and eager loading effectively. This video walks through real-world examples and performance tips._
26+
27+
---
28+
29+
💡 **Tip:** Use tools like Laravel Debugbar or `DB::listen()` to analyze query execution and memory usage in real time.

public/vaahstore-api/addresses/index.yaml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,27 @@ get:
55
description: Retrieve list of all the addresses.
66
operationId: getAddresses
77
parameters:
8-
- '$ref': '../vaahstore.yaml#/components/parameters/page'
9-
- '$ref': '../vaahstore.yaml#/components/parameters/rows'
10-
- '$ref': '../vaahstore.yaml#/components/parameters/filter_q'
11-
- '$ref': '../vaahstore.yaml#/components/parameters/filter_is_active'
12-
- '$ref': '../vaahstore.yaml#/components/parameters/filter_is_default'
13-
- '$ref': '../vaahstore.yaml#/components/parameters/filter_trashed'
14-
- '$ref': '../vaahstore.yaml#/components/parameters/filter_date'
15-
- '$ref': '../vaahstore.yaml#/components/parameters/status'
16-
- '$ref': '../vaahstore.yaml#/components/parameters/users'
8+
- $ref: '../vaahstore.yaml#/components/parameters/page'
9+
- $ref: '../vaahstore.yaml#/components/parameters/rows'
10+
- $ref: '../vaahstore.yaml#/components/parameters/frontend_ui'
11+
- name: fetch_all
12+
in: query
13+
required: true
14+
schema:
15+
type: boolean
16+
description: "If `fetch_all=true`, load all addresses of a logged-in user without pagination."
17+
- $ref: '../vaahstore.yaml#/components/parameters/filter_q'
18+
- $ref: '../vaahstore.yaml#/components/parameters/filter_is_active'
19+
- $ref: '../vaahstore.yaml#/components/parameters/filter_is_default'
20+
- $ref: '../vaahstore.yaml#/components/parameters/filter_trashed'
21+
- $ref: '../vaahstore.yaml#/components/parameters/filter_date'
22+
- $ref: '../vaahstore.yaml#/components/parameters/status'
23+
- $ref: '../vaahstore.yaml#/components/parameters/users'
1724

1825

1926
responses:
2027
'200':
21-
description: List retrieved Successfully
28+
description: List retrieved Successfully Based on the `?frontend_ui=primevue&fetch_all=true`
2229
content:
2330
application/json:
2431
schema:

public/vaahstore-api/authentication/paswordResetCode.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ post:
3333
type: boolean
3434
example: true
3535
data:
36-
type: array
37-
items:
38-
type: object
39-
example: [ ]
36+
type: object
37+
example: null
4038
messages:
4139
type: array
4240
items:

public/vaahstore-api/authentication/resetPassword.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ post:
4242
type: boolean
4343
example: true
4444
data:
45-
type: array
46-
items:
47-
type: object
48-
example: [ ]
45+
type: object
46+
example: null
4947
messages:
5048
type: array
5149
items:

public/vaahstore-api/authentication/signOut.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ post:
2525
"Logout successfully"
2626
]
2727
data:
28-
type: array
29-
description: The data returned after successful signout (typically empty).
30-
example: []
28+
type: object
29+
example: null
3130

3231
'422':
3332
description: Bad Request, validation errors occurred.

public/vaahstore-api/authentication/signin.yaml

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,74 @@ post:
5454
success:
5555
type: boolean
5656
example: true
57+
messages:
58+
type: array
59+
items:
60+
type: string
61+
example: [ "SignIn Successfully." ]
5762
data:
5863
type: object
64+
description: The authenticated user data including the API token.
5965
properties:
60-
item:
61-
type: object
62-
description: The authenticated user data including the API token.
63-
properties:
64-
id:
65-
type: integer
66-
description: The unique identifier for the user.
67-
email:
68-
type: string
69-
format: email
70-
description: The email address of the user.
71-
username:
72-
type: string
73-
description: Username of the customer/user.
74-
first_name:
75-
type: string
76-
description: FIrst name of the customer/user.
77-
name:
78-
type: string
79-
description: "Customer's full name."
80-
created_ip:
81-
type: string
82-
description: "IP address of the user who created the customer record."
83-
api_token:
84-
type: string
85-
description: The API token for authenticating future requests.
66+
id:
67+
type: integer
68+
description: The unique identifier for the user.
69+
uuid:
70+
type: string
71+
nullable: true
72+
description: UUID of the user.
73+
email:
74+
type: string
75+
format: email
76+
description: The email address of the user.
77+
username:
78+
type: string
79+
description: Username of the customer/user.
80+
first_name:
81+
type: string
82+
description: First name of the customer/user.
83+
last_name:
84+
type: string
85+
description: Last name of the user.
86+
phone:
87+
type: integer
88+
description: Phone number of the user.
89+
name:
90+
type: string
91+
description: Customer's full name.
92+
created_ip:
93+
type: string
94+
nullable: true
95+
description: IP address of the user who created the customer record.
96+
updated_by:
97+
type: integer
98+
nullable: true
99+
description: User ID who last updated the record.
100+
updated_at:
101+
type: string
102+
format: date-time
103+
description: Timestamp when the record was last updated.
104+
created_by:
105+
type: integer
106+
nullable: true
107+
description: User ID who created the record.
108+
created_at:
109+
type: string
110+
format: date-time
111+
description: Timestamp when the record was created.
112+
avatar:
113+
type: string
114+
format: uri
115+
description: URL to the avatar image.
116+
api_token:
117+
type: string
118+
description: The API token for authenticating future requests.
119+
expires_at:
120+
type: string
121+
format: date-time
122+
description: Expiry datetime of the API token.
123+
124+
86125
422:
87126
description: Bad Request, validation errors occurred.
88127
content:

public/vaahstore-api/authentication/signinOTP.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ post:
3434
type: boolean
3535
example: true
3636
data:
37-
type: array
38-
items:
39-
type: object
40-
example: [ ]
37+
type: object
38+
example: null
4139
messages:
4240
type: array
4341
items:

public/vaahstore-api/authentication/signup.yaml

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,33 +56,65 @@ post:
5656
]
5757
data:
5858
type: object
59+
description: The authenticated user data including the API token.
5960
properties:
60-
item:
61-
type: object
62-
description: The authenticated user data including the API token.
63-
properties:
64-
id:
65-
type: integer
66-
description: The unique identifier for the user.
67-
email:
68-
type: string
69-
format: email
70-
description: The email address of the user.
71-
username:
72-
type: string
73-
description: Username of the customer/user.
74-
first_name:
75-
type: string
76-
description: FIrst name of the customer/user.
77-
name:
78-
type: string
79-
description: "Customer's full name."
80-
created_ip:
81-
type: string
82-
description: "IP address of the user who created the customer record."
83-
api_token:
84-
type: string
85-
description: The API token for authenticating future requests.
61+
id:
62+
type: integer
63+
description: The unique identifier for the user.
64+
uuid:
65+
type: string
66+
nullable: true
67+
description: UUID of the user.
68+
email:
69+
type: string
70+
format: email
71+
description: The email address of the user.
72+
username:
73+
type: string
74+
description: Username of the customer/user.
75+
first_name:
76+
type: string
77+
description: First name of the customer/user.
78+
last_name:
79+
type: string
80+
description: Last name of the user.
81+
phone:
82+
type: integer
83+
description: Phone number of the user.
84+
name:
85+
type: string
86+
description: Customer's full name.
87+
created_ip:
88+
type: string
89+
nullable: true
90+
description: IP address of the user who created the customer record.
91+
updated_by:
92+
type: integer
93+
nullable: true
94+
description: User ID who last updated the record.
95+
updated_at:
96+
type: string
97+
format: date-time
98+
description: Timestamp when the record was last updated.
99+
created_by:
100+
type: integer
101+
nullable: true
102+
description: User ID who created the record.
103+
created_at:
104+
type: string
105+
format: date-time
106+
description: Timestamp when the record was created.
107+
avatar:
108+
type: string
109+
format: uri
110+
description: URL to the avatar image.
111+
api_token:
112+
type: string
113+
description: The API token for authenticating future requests.
114+
expires_at:
115+
type: string
116+
format: date-time
117+
description: Expiry datetime of the API token.
86118

87119
'422':
88120
description: "Validation error"

0 commit comments

Comments
 (0)