Skip to content

Mohcin Bounouara

Thoughts about software engineering and life

Fixing Object Pagination with Laravel and Inertia.js that gives empty data

Problem When working with Laravel and Inertia.js, pagination returns an object instead of an array. This can make looping over the results a bit tricky, as the expected array structure isn’t accessible. For example, in a typical Laravel controller method like this: You might see the data coming through correctly as a prop in your Continue reading “Fixing Object Pagination with Laravel and Inertia.js that gives empty data”

Fixing Laravel Route Conflicts, that led to 404 Errors for Existing Routes

Problem: Recently, while developing a feature to update resources in my Laravel app, I faced an unexpected issue: the create functionality, which had been working previously, suddenly stopped functioning. When I tried accessing the jobs/create route, it led to a 404 page, even though my unit tests confirmed that the route existed and the functionality Continue reading “Fixing Laravel Route Conflicts, that led to 404 Errors for Existing Routes”

Understanding Method Spoofing in Laravel

Title: Understanding Method Spoofing in Laravel When working with request/response methods, different HTTP methods like GET, POST, PUT, and PATCH have custom purposes. POST is generally used for creating resources, while PUT and PATCH are intended for updates. But as a developer, you’ll often see POST used for updates too. This happens due to browser Continue reading “Understanding Method Spoofing in Laravel”

Pivot table in Laravel

When you work on an app that requires a many-to-many relationship between tables, you often need a pivot table in your database to manage the associations between records. Let’s consider a simple database schema as an example: Suppose you need to link each post with one or multiple categories. In this scenario, you require a Continue reading “Pivot table in Laravel”