de en es fr nl pl pt sv zh

laravel

How to format code with Laravel Pint automatically on Git Commit

Adithya

I have been using Laravel Pint for a while now. Initially, I ran pint to format my code manually and across all files. Recently, I have been making use of Git pre-commit hooks to apply code format changes to only files that have been modified. I use this both for Arbeitnow with Laravel and the...

Fixing Laravel 10 return type error in Controller

Adithya

Laravel 10 added support for types and it's great. In some cases, you might see errors if the defined types and actual return types do not match.When you create a new Controller using php artisan make:controller IndexController , you get this default stub.<?php namespace...

Statamic: Find & Replace in Bard

Adithya

When working with Statamic Bard, I wanted to find and replace certain occurrence of a word - say find "Lorem ipsum" and replace with "LOREM IPSUM". I used this great addon called Bard Mutator (v1 and v2). I'm using Statamic v3.4 with Tiptap v2 and Bard Mutator v2.To get started:Make sure you have...

Cloudflare purging page cache with Laravel & Statamic

Adithya

I use Cloudflare to cache pages for a day. Recently I built the Arbeitnow blog using Statamic. When I update the content, I want the cache to be updated and the latest changes to be shown to the visitor.When I deploy changes to content, I added a new Laravel command as part of the deployment flow....

Elasticsearch API key & PHP

Adithya

When you enable XPACK security in Elasticsearch, your clients (my website in this case) requires authentication to be setup. If you do not setup proper authentication, you will get similar errors.Elastic\Elasticsearch\Exception\ClientResponseException 401 Unauthorized: { "error": {...

Data Providers in PHPUnit

Adithya

When I built a Salary Calculator for Germany using Laravel, I started covering the code with Unit Tests using PHPUnit. This particularly came in handy when I had to cover more edge cases as I was able to trust the calculation. One of the features that I didn't know until that point was Data...

Laravel - Remove slashes on JSON Response

Adithya

I built an API endpoint in Laravel - a JSON response with a body. When I looked at the formatted response using a JSON formatter, it looked good when I was working on Salary Calculation in Germany.return response()->json(['url' => 'https://www.domain.com/api/test']); I expected a response...

Laravel Translation for Subfolders

Adithya

I organized my language translation folder in Laravel in this way- resources - de - en - app.php - subfolder - file.phpTo access the translation keys in app.php, it's straightforward as described in the Laravel documentation. To access a key from app.php, you...