Nginx rewrite rules and match only beginning of string

A nice little gotcha. Often when you write Nginx rules, you forget that it matches everything in the string. Imagine if you want this redirect /product-a -> /category-1/product-a

Test event inside an Eloquent observer

Most times you test that events are fired by adding Event::fake() to your tests. This will make Event::assertDispatched(SomeEvent::class) to return true. However, no events will trigger as soon...

Mock Laravel Cache remember for ever

Sometimes you want to make sure certain things are cached properly. With mocking this is possible. In this example I will show how to test Cache::rememberForever and see the...

Cannot add foreign key constraint

The most common error I see when trying to create foreign key constraints is you forget that the colmuns must have the same type, including unsigned() if unsigned. In...

Fix HTTP2 in cURL and Laravel Valet

While working with Apple’s new API for push notifications and Laravel, I had to make requests to Apple’s servers via http2 from my local Laravel Valet instance. Lately, the brew...