Tag: php

Using keys with reduce in Laravel

There are some quite important functions that are being very commonly used to transform data, even across languages, that modern approaches to solving problems greatly prefer. Many things in theory could fit such definition, but right now I am talking about map, reduce or even fi…

Convenient relationship factories in Laravel 8

One of the changes in Laravel 8 was the overhaul of the model factories which led to factories being namespaced. Seeders are also affected in the same way, but this is a different topic for now. Now I did not paid enough attention to grasp why such change was introduced or even n…

A basic InertiaJS test macro

I've made a macro for the Illuminate\Testing\TestResponse class that I put into the TestCase.php file which is a part of pingcrm-svelte. I currently use this short macro in basically all HTTP tests for Inertia related endpoints in Laravel, so unless I am doing something wrong, it…

Prettier PHP plugin in vim

After spending a few hours trying to make chained methods in PHP arrange itself below one and each other in a tidy manner, I have finally found a solution. In other words, on a file save I wanted to go from this: $this->user->account->organizations()->saveMany(Organiz…

Install PHP7 with composer on Arch

After adding support for PHP 8.0, Arch news reported they are keeping legacy PHP7 packages available back in January. I was quite out of PHP scene for now, but recently, I had to test something. The test obviously required the php core package, now the version 8.0 and a second ha…