Laravel & Eloquent Tutorials

Laravel is a web application framework with expressive, elegant syntax and a rich set of features for building robust, full-stack applications in PHP.

Eloquent ORM is an object-relational mapper (ORM) that is included by default within the Laravel framework. An ORM is software that facilitates handling database records by representing data as objects, working as a layer of abstraction on top of the database engine used to store an application’s data. Eloquent makes it enjoyable to interact with your database, providing an object-oriented approach to inserting, updating, and deleting database records, while also providing a streamlined interface for executing complex SQL queries. Eloquent also supports defining and querying relationships between different models, such as one-to-one, one-to-many, many-to-many, and polymorphic relationships. Eloquent is one of the reasons why thousands of developers love Laravel.

This series of tutorials covers everything you need to know about Laravel and Eloquent ORM. Let’s get started!

1 When to use and when not to use Laravel

2 Laravel Learning Path for Non-Experienced Developers

3 How to Set Up Artisan CLI in Windows

4 How to install Laravel on Windows and Mac

5 How to Set Up Artisan CLI on Mac

6 How to Install and Configure Laravel in Ubuntu (with Nginx)

7 How to deploy Laravel to DigitalOcean with Laravel Forge

8 Deploying Laravel in production with Apache and Let's Encrypt

9 How to create a Laravel project in the current directory

10 How to Upgrade an Existing Laravel Project to the Latest Version

11 How to run Laravel in a subdirectory of a domain

12 How to use environment variables in Laravel

13 3 Ways to Run Laravel on a Custom Port

14 How to set up Laravel with Docker Compose

15 How to Dockerize a Laravel app for production

16 How to determine the current environment in Laravel

17 How to Encrypt Environment Files in Laravel

18 Laravel folder structure: Understanding the big picture

19 How to Run Laravel in Debug/Development Mode

20 How to run Laravel in maintenance mode

21 How to Fix VS Code IntelliSense for Laravel Facades

22 How to Define Routes in Laravel

23 How to extract route parameters in Laravel

24 How to get the current route in Laravel

25 How to Define Fallback Routes in Laravel

26 Using required and optional route parameters in Laravel

27 How to inject dependencies into route closures in Laravel

28 Laravel: How to constrain routes with regular expressions

29 Naming Routes in Laravel: A Practical Guide

30 How to Generate QR Codes in Laravel (the right way)

31 Subdomain Routing in Laravel: A Developer's Guide

32 Route prefixing and grouping in Laravel: A complete guide

33 Using Enum on Laravel routes: A practical guide

34 Specifying the HTTP method for Laravel routes

35 How to Set Up and Configure Redis in Laravel

36 How to Implement Rate Limiting in Laravel

37 Handling CORS in Laravel: A Practical Guide

38 Route Caching in Laravel: A Complete Guide

39 Using Livewire with Laravel: A Developer's Guide

40 Laravel: How to pass data to Blade templates

41 Laravel: How to render a PHP array with Blade

42 Laravel: How to conditionally render data with Blade

43 Laravel - How to including Blade subviews

44 Laravel Blade: How to escape dangerous HTML & JavaScript

45 Laravel: Ways to use global variables in Blade templates

46 Laravel: How to Pass PHP Variables to JavaScript in Blade Templates

47 Laravel: How to link to static assets in Blade templates

48 Laravel: How to render JSON data in Blade templates

49 How to disable/enable CSRF protection in Laravel

50 How to Enable/Disable Blade Template Caching in Laravel

51 Laravel: Connect to different databases based on routes

52 Laravel: How to build layouts with Blade

53 Laravel error: Variable undefined in Blade template (4 solutions)

54 Laravel: How to use ternary operators in Blade templates

55 Laravel: How to make comments in Blade templates

56 How to define global helper functions in Laravel

57 Laravel error: Invalid request (Unsupported SSL request)

58 Laravel: How to Conditionally Display an Image with Blade

59 How to use Tailwind CSS with Laravel

60 How to set up Bootstrap with Laravel

61 How to use Font Awesome in Laravel

62 Laravel + Eloquent: Store categories and subcategories in the same table

63 Laravel: How to retrieve URL parameters in Blade views

64 Laravel + Eloquent: Storing comments and nested comments

65 Laravel: How to generate raw HTML string from Blade template

66 Laravel: Displaying a default/placeholder value with Blade

67 Laravel Blade: Using '@yield' and '@section' directives

68 Laravel Blade: Rendering a list of dynamic checkboxes

69 Laravel: Render links with dynamic href attributes in Blade

70 Laravel Blade: How to Enable Auto-completion in VS Code

71 Laravel: Rendering a table with PHP array data in Blade

72 Laravel Blade: How to show a view only to logged-in users

73 Laravel: How to break a foreach loop in Blade

74 Laravel: Styling odd/even rows in a Blade loop (5 approaches)

75 Directives in Laravel Blade: Tutorial & Examples

76 Laravel: How to append to a section in Blade

77 Laravel Blade: Set dynamic page title and meta description

78 Laravel: How to include an HTML file in Blade template

79 Laravel Blade: How to Draw Charts from PHP Arrays

80 Laravel: Using Stack in Blade Templates

81 Laravel: How to display SVG images in Blade templates

82 Laravel: How to create a custom 404 page with Blade

83 Laravel: How to define custom Blade directives

84 How to Define Middleware in Laravel

85 How to assign middleware to routes in Laravel

86 How to create global middleware in Laravel

87 How to Sort Middleware in Laravel

88 How to group middleware in Laravel

89 How to pass parameters to middleware in Laravel

90 How to Terminate Middleware in Laravel

91 How to create controllers in Laravel: A practical guide

92 How to create localizable (i18n) routes in Laravel

93 How to handle exceptions in Laravel: A practical guide

94 How to Inject Dependencies into Controllers in Laravel

95 Lifecycle of a Laravel request: Explained with examples

96 How to Get and Parse Query String in Laravel

97 How to extract request headers in Laravel

98 How to get user's IP address in Laravel

99 How to get User-Agent header in Laravel

100 Laravel: How to Extract Auth Token from Request Headers

101 How to retrieve input data from request in Laravel: An example-driven guide

102 Laravel: How to get request body

103 How to handle JSON POST request in Laravel

104 Laravel + Blade: How to Render Array Data with Tables

105 Using cursor-based pagination in Laravel + Eloquent

106 How to upload and validate files in Laravel

107 Laravel + Eloquent: How to Build a Rating System

108 How to Serve Static Files in Laravel

109 How to validate input data in Laravel: A practical guide

110 How to Attach Headers to a Response in Laravel

111 How to Set a Custom HTTP Response Code in Laravel

112 How to return JSON response in Laravel

113 How to return a CSV file in Laravel

114 How to create an XML sitemap in Laravel

115 How to create an RSS feed in Laravel

116 How to return stream response in Laravel (for large files)

117 File Response in Laravel: An Example-Driven Guide

118 How to define type hints for request parameters in Laravel

119 How to define type hints for response in Laravel

120 Laravel: How to Check if a View Exists

121 View Composer in Laravel: A Practical Guide

122 Laravel: How to Compress Response with Gzip

123 How to log requests in Laravel

124 Inline and Anonymous Components in Laravel Blade: A Practical Guide

125 Laravel Blade: How to access data in a parent view

126 How to Use React with Laravel – Integrating Your Front-End with PHP Backend

127 How to use Vue.js with Laravel

128 How to integrate Angular with Laravel

129 How to integrate Next.js with Laravel: A practical guide

130 Managing sessions in Laravel: A practical guide

131 Laravel: How to check if an item exists in the session

132 Using array session values in Laravel: A developer's guide

133 Flashing Data to Session in Laravel: Explained with Examples

134 Session Blocks in Laravel: Explained with Examples

135 How to validate nested array input in Laravel

136 How to Validate Email and Password in Laravel

137 How to Hash Passwords the Right Way in Laravel

138 Laravel: How to Validate a Form with Optional Fields

139 How to upload multiple files in Laravel

140 Laravel: Using Validator with Custom Error Messages

141 Working with Laravel Artisan Console: A Practical Guide

142 Using laravel-websocket in Laravel to Build Real-Time Apps

143 How to store and read data from cache in Laravel

144 Collections in Laravel: A Deep Dive with Examples

145 How to Send Email in Laravel: The Right Way

146 How to implement password login in Laravel

147 How to implement password reset in Laravel

148 How to implement Google Sign-In in Laravel

149 How to implement Facebook Login in Laravel

150 Laravel: Redirecting user to a specific page after login

151 Laravel: How to Log Out a User (Basic & Advanced Techniques)

152 Laravel: How to retrieve authenticated user

153 Authorization Role in Laravel: A Practical Guide

154 Laravel: How to verify permissions in Blade templates

155 Observers and Event Listeners in Laravel: A Practical Guide

156 Laravel: Sending email with attachments

157 Laravel + Eloquent: Design a Simple URL Shortening Service

158 SMS Notifications in Laravel: A Practical Guide

159 How to verify email in Laravel (with examples)

160 How to Encrypt Data in Laravel: Tutorial & Examples

161 How to create a shopping cart in Laravel

162 How to schedule tasks in Laravel: A developer's guide

163 How to run background, heavy tasks in Laravel: An in-depth guide

164 How to integrate PayPal in Laravel: A developer's guide

165 How to add Stripe payment gateway to Laravel

166 How to implement CI/CD in Laravel: A practical guide

167 How to connect to MySQL database in Laravel

168 How to Execute SQL Queries in Laravel

169 Eloquent: How to auto-delete old records after N days

170 How to connect to PostgreSQL database in Laravel

171 Laravel + Blade: How to Create a “Table of Contents”

172 How to connect to SQLite database in Laravel

173 How to connect to multiple databases in Laravel

174 Laravel: How to set a custom path for '/public' directory

175 Laravel QueryBuilder vs Eloquent ORM: Which to use?

176 Laravel Error: Missing the Mcrypt PHP extension

177 Solving Laravel Error: Your Session Has Expired

178 Fixing Laravel Error: File laravel.log could not be opened (4 solutions)

179 Laravel error: Specified key was too long; max key length is 767 bytes

180 Laravel – Syntax error or access violation: 1055 Error Resolution

181 Solving Laravel PDOException: Could not Find Driver (MySQL, PostgreSQL)

182 How to Relocate the 'public' Directory in Laravel

183 Laravel Issue: The Page Has Expired Due to Inactivity

184 Laravel Migration Error: Cannot add foreign key constraint (causes & solutions)

185 Solving Laravel ErrorException: Trying to get property of non-object (4 solutions)

186 Solving Laravel MethodNotAllowedHttpException (5 solutions)

187 Solving Laravel Error: View not found (3 solutions)

188 Protecting Routes in Laravel: A Practical Guide

189 [Solved] Laravel ErrorException: Session store not set on request (4 solutions)

190 How to Clear Cache in Laravel

191 Laravel Blank Page Error: Causes & Solutions

192 Laravel Error: All routes return 404 not found except '/' (6 solutions)

193 Laravel Queue System: Explained with Examples

194 Laravel error: SSL operation failed with code 1 (3 solutions)

195 How to return a PDF file in Laravel

196 Laravel error: CSS & JS files not loading in production (7 solutions)

197 Laravel Fatal error: Class 'Illuminate\Foundation\Application' not found

198 Laravel error: Class 'Illuminate\Html\HtmlServiceProvider' not found

199 Laravel Uncaught ReflectionException: Class log does not exist - Error Fixing Guide

200 Laravel Error: Class 'App\Http\Controllers\admin\Auth' Not Found

201 How to use SendGrid to send email in Laravel

202 How to use MailGun to send email in Laravel

203 Laravel 403 Forbidden Error: You don't have permission to access '/' on this server

204 Handling TokenMismatchException in Laravel: A Practical Guide

205 Laravel Error 405: Method Not Allowed - How to Fix

206 Fixing Laravel Error: Access has been blocked by CORS policy (3 solutions)

207 Laravel error - SQLSTATE[42S22]: Column not found: 1054 Unknown column (3 solutions)

208 Solving Laravel Error: Missing Required Parameters for Route

209 How to add custom validation rules in Laravel (with examples)

210 Laravel: Rendering CSV data in an HTML table

211 How to validate data with regex in Laravel

212 Laravel & Eloquent: Seeding a CSV file into a MySQL database

213 Laravel: Using Faker to Seed Sample Data (for Testing & Practice)

214 Laravel Error 400: Bad Request - How to Fix

215 Laravel: How to create custom Faker providers

216 Laravel Error: Base table or view not found

217 Laravel: Generating sample users with passwords using Faker

218 Laravel Query Builder: Get All Records from Table

219 Laravel + Faker: Generate user with email and gender based on name

220 Laravel Query Builder: Get Records with OFFSET and LIMIT

221 i18n in Laravel: A Practical Guide (with Examples)

222 Laravel query builder: Get the latest/oldest record from table

223 Laravel query builder: Excluding specific columns from query result

224 Chunking in Laravel Query Builder: Tutorial & Examples

225 Streaming Results Lazily in Laravel Query Builder: Tutorial & Examples

226 Laravel Query Builder Aggregation: Count, Sum, Max, Min, Average

227 Laravel Query Builder: Select Distinct Records

228 Laravel Query Builder: Using 'WHERE' Clause

229 Laravel Query Builder: Using ‘AND’ and ‘OR’ Operators

230 Laravel Query Builder: Using ‘ORDER BY’ Clause

231 Executing Subqueries in Laravel Query Builder: Tutorial & Examples

232 Inner Join in Laravel Query Builder: Tutorial & Examples

233 Left/Right Join in Laravel Query Builder: Tutorial & Examples

234 How to Union Queries in Laravel Query Builder

235 Laravel Query Builder: Find Results Between a Range of Numbers

236 Laravel Query Builder: Search Results with 'LIKE' Operator

237 Laravel Query Builder: Selecting Rows Between Two Dates

238 Laravel Query Builder: Select rows in last day/week/month/year

239 Laravel Query Builder: Find rows where column is null/not null

240 Using Multiple 'WHERE' Conditions in Laravel Query Builder

241 How to View Raw SQL Query Generated by Laravel Query Builder

242 Laravel Query Builder: How to get a random row

243 Laravel Query Builder: Select N Random Rows the Right Way

244 Using 'GROUP BY' and 'HAVING' in Laravel Query Builder

245 Upsert in Laravel Query Builder: Tutorial & Examples

246 How to insert new record with Laravel Query Builder

247 Bulk Insert/Update in Laravel Query Builder: Tutorial & Examples

248 Laravel Query Builder: Insert and Get ID of Last Inserted Row

249 How to update JSON column in Laravel Query Builder

250 Increment and Decrement of Column Values in Laravel Query Builder

251 Deleting Records with Conditions in Laravel Query Builder

252 Shared Locking in Laravel Query Builder: A Practical Guide

253 Laravel Query Builder: 'GREATER THAN' and 'LESS THAN' Operators

254 Laravel Query Builder: Select rows where IDs are in an array

255 4 Ways to Define Model in Eloquent (Laravel)

256 How to use custom table name in Eloquent (Laravel)

257 Eloquent: Creating table with auto-incrementing ID

258 Using UUID and ULID in Laravel Eloquent

259 created_at and updated_at columns in Eloquent (Laravel)

260 How to Format Date Time in Eloquent (Laravel)

261 Eloquent: How to specify a different database connection

262 Eloquent: Define model with optional/nullable fields

263 Eloquent: Create model with default values

264 Eloquent: How to Safely Change Column Name in Laravel

265 Laravel Eloquent ORM: How to Alter a Table

266 Eloquent: How to DROP/TRUNCATE a table

267 Model Events in Eloquent: A Comprehensive Guide

268 Understanding Scopes in Eloquent (with examples)

269 Mutators and Accessors in Eloquent: A Practical Guide

270 Polymorphic Relations in Eloquent: Explained with Examples

271 Eloquent: Convert query result to PHP array

272 Eloquent: How to Convert Query Result to JSON

273 How to chunk results in Eloquent (Laravel)

274 Using the lazy() and the cursor() methods in Eloquent (Laravel)

275 Eloquent: Selecting Specific Columns from a Table

276 Eloquent: Filtering query results with whereColumn() method

277 Eloquent: Sorting Results with orderBy() Method

278 Eloquent: Limiting Query Results with limit() Method

279 Laravel & Eloquent: Pagination Examples

280 Eloquent: Sorting Records by Multiple Columns

281 Eloquent: How to retrieve last/first record from table

282 Using where() method in Eloquent to filter query results

283 Eloquent Upsert: Update if exists, Insert if not

284 Eloquent Aggregates: Count, Sum, Max, Min, Average

285 Eloquent: Counting Records Based on a Condition (6 Techniques)

286 Eloquent Aggregates: Count, Sum, Max, Min, Average

287 How to insert/update/delete a record with Eloquent

288 How to Bulk Insert Data with Eloquent in Laravel

289 Eloquent: How to Check if a Model Attribute Changed

290 Working with JSON columns in Eloquent: A Practical Guide

291 Eloquent: Delete multiple records with an array of IDs

292 Eloquent: Find records where column is null/not null

293 Eloquent: Find Records Between Two Dates

294 Eloquent: Find records in last day/week/month/year

295 Eloquent: 4 ways to select a random record.

296 Eloquent: 5 ways to select N random records

297 Weighted random selection in Eloquent: A Practical Guide

298 Explore soft deletes in Eloquent: A developer's guide

299 How to Restore Soft Deleted Models in Eloquent

300 Pruning Models in Eloquent: Tutorial & Examples

301 How to Replicate a Model in Eloquent

302 How to Compare Two Models in Eloquent

303 How to register and use closures in Eloquent

304 How to define and use observers in Eloquent

305 How to Temporarily Disable Events in Eloquent

306 Eloquent ORM: How to use multiple 'WHERE' clauses

307 Eloquent ORM: How to Use Multiple Database Connections

308 Data transactions and commit/rollback in Eloquent

309 How to get the raw SQL query generated by Eloquent

310 How to execute subqueries in Eloquent

311 Eloquent: Defining tables with one-to-one relationships

312 Laravel Eloquent: How to Cascade Delete Related Models

313 Laravel Eloquent: Sorting Results on Related Models

314 Laravel Eloquent: Using groupBy() to group results by a column

315 Laravel Eloquent: How to add UNIQUE constraint

316 Laravel Eloquent: Column with Unsigned Integer

317 Laravel + Eloquent: How to Group Data by Multiple Columns

318 Using Table Aliases in Eloquent: A Practical Guide

319 Laravel Eloquent: Finding SUM/COUNT/AVG of each group

320 Laravel Eloquent: Find MIN/MAX in each group

321 Laravel Eloquent: Working with Self-Joining Tables

322 Laravel Eloquent: Counting records in related tables

323 Laravel Eloquent: 'IN' and 'NOT IN' operators

324 Laravel Eloquent: 3 Ways to Check if a Record Exists

325 Eloquent: 5 Ways to Exclude Specific Columns from Query Result

326 Working with one-to-many relationships in Eloquent (with examples)

327 Using many-to-many relationships in Eloquent (with examples)

328 Laravel Eloquent: How to merge multiple collections

329 Laravel Eloquent error: A facade root has not been set (5 solutions)

330 Laravel Eloquent: How to Alias a Column

331 Laravel Eloquent: How to Compare Numeric/String Columns

332 Laravel Eloquent: How to Implement Full-Text Search

333 Laravel Eloquent: How to Implement Case-Insensitive Search

334 Laravel Eloquent: How to Implement Page Pagination

335 Laravel Eloquent: How to create 'infinity scroll' pagination

336 Laravel Eloquent: How to Add Index to a Column

337 Laravel Eloquent: How to Select Data with Raw SQL Queries

338 Using 'CASE WHEN' in Laravel Eloquent

339 Eloquent issue: Adding 'Unique' constraint to a column with duplicate values

340 Eloquent: Using Multiple Foreign Keys in a Relationship

341 Eloquent QueryException: SQLSTATE[42000]: Syntax error or access violation - Causes & Solutions

342 Laravel Eloquent: Using 'LIKE' and 'NOT LIKE' operators

343 Eloquent: How to get an array of all table names

344 What are pivot tables in Laravel Eloquent: Explained with examples

345 Laravel Eloquent: attach(), detach(), and sync() methods

346 Laravel Eloquent: How to cast data types of model attributes

347 Laravel Eloquent: Storing arrays and nested arrays in database

348 Laravel Eloquent error: 1615 Prepared statement needs to be re-prepared

349 How to optimize Laravel Eloquent queries (with examples)

350 Laravel Eloquent: Using whereJSONContains() to filter JSON columns

351 Eager Loading in Laravel Eloquent: Explained with Examples

352 How to disable/enable timestamps in Laravel Eloquent

353 Laravel Eloquent: 'EQUAL' and 'NOT EQUAL' operators

354 Eloquent: Sorting rows but empty values at the end/beginning

355 Using 'INNER JOIN' in Laravel Eloquent

356 Using 'LEFT JOIN' in Laravel Eloquent

357 Using 'RIGHT JOIN' in Laravel Eloquent

358 Laravel Eloquent: Change column type with migration

359 Laravel Eloquent: Change format of created_at and updated_at columns

360 Eloquent error: Cannot add a NOT NULL column with default value NULL

361 Using 'UNION' in Laravel Eloquent

362 Can you use Eloquent ORM without Laravel?

363 Using belongsTo() and hasMany() in Laravel Eloquent

364 Laravel Eloquent: Return a fallback/default value if record not found

365 Laravel Eloquent: CRUD Example

366 How to implement GraphQL in Laravel

367 How to create REST API with Laravel (no views)

368 Laravel Example: Defining Routes for an E-commerce Platform

369 Laravel Example: Defining routes for a social media platform

Notify of
Inline Feedbacks
View all comments