In this blogpost I’m going to show you how to merge validation of 4 different type of requests on the same model into one FormRequest class.

When you start a project in Laravel, soon you most likely will be handling form validation. The framework provides different ways of dealing with validation, for example by adding the validation rules inside your controller:

class PostController extends Controller
{
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
'date' => 'sometimes|date',
]);

// The blog post is valid...
}
}

There is nothing wrong with this…


While converting my ten-ish year old multi-tenant SaaS application from a dead framework to Laravel, it seems a good opportunity to implement an API for users to consume. Couldn’t be that difficult in Laravel, right? Well, it took me a day or so to figure things out, but looking back it’s quite easy to achieve what I was looking for. Most of the time spent was finding the right solution between all the possibilities that one can find when looking for ways to implement an API with Laravel.

Requirements

  • Provide a REST API for most (if not all) resources
    (meaning following the…


Recently I started to rebuild an ten-ish year old SaaS product in Laravel from an abandoned framework. The product needs multi tenancy with separate databases for each tenant. After looking into some multi tenancy packages out there and watching the video by Mohamed Said I’ve chosen to go with the brand new laravel-multitenancy package by Spatie because it provides a simple and unopinionated approach into multi tenancy.

The package provides an artisan command to run other artisan commands for each tenant in the application, for example to migrate each tenant:

This command will loop through each…

Jasper Briers

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store