PHPackages                             mmerlijn/laravel-helpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mmerlijn/laravel-helpers

ActiveProject[Utility &amp; Helpers](/categories/utility)

mmerlijn/laravel-helpers
========================

Laravel helpers: casts and facades

v3.1.6(3mo ago)09131MITPHPPHP ^8.2

Since Mar 2Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/mmerlijn/laravel-helpers)[ Packagist](https://packagist.org/packages/mmerlijn/laravel-helpers)[ RSS](/packages/mmerlijn-laravel-helpers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (22)Used By (1)

Laravel Helpers
===============

[](#laravel-helpers)

### Summary

[](#summary)

Casts

- Phone Rules

Rules

- Bsn
- Requestnr

Facades

- Distance

Traits

- AddressModelTrait
- NameModelTrait

install
=======

[](#install)

```
composer require mmerlijn/laravel-helpers

```

For flash message
-----------------

[](#for-flash-message)

add to app.js

```
import flashHandler from '../../vendor/mmerlijn/laravel-helpers/resources/js/flashHandler';

Alpine.data('flashHandler', flashHandler)
window.flash = msg => window.dispatchEvent(new CustomEvent('flash', {detail: msg}))
```

add to the preferred layout.blade (bottom of body)

```

```

### Flash usage

[](#flash-usage)

```
Flash::message('Hello World')->type('noticee')->add();
```

or

```
Click me
```

or

```
flash('Hi, all!')
```

Casts
-----

[](#casts)

### Phone

[](#phone)

Setter will cast phone to only numbers string

Getter will cast phone to a readable format

` Important!!` fill city field before phone fields for the use of kental

##### Example

[](#example)

```
//In YourModel.php

    protected $casts = [
        'phone' => Phone::class,
    ];

//setter => 0612345678
//getter => PhoneModel class

//methods
$model->phone->get(); // returns 06 1234 5678
$model->phone->set(); // returns 0612345678
$model->phone->smsPhone(); //returns +31612345678 or exception
$model->phone->withCountryCode('it'); //returns +39612345678
```

### Initials

[](#initials)

Setter will strip all none alphabetic characters

Getter will split all letters with a dot

##### Example

[](#example-1)

```
//In YourModel.php

    protected $casts = [
        'initials' => Initials::class,
    ];

//setter => BAR
//getter => B.A.R.
```

Rules (validators)
------------------

[](#rules-validators)

### BSN

[](#bsn)

Validates Dutch BSN

##### Example

[](#example-2)

```
Validator::make([],[
  'bsn'=> [new Bsn]
]);
```

### Requestnr

[](#requestnr)

validate requestnr

regex: '/^((ZD|ZP|CW){1}\\d{8}|(PG){1}\\d{9})$/i'

```
Validator::make([],[
  'request_nr'=> [new Requestnr]
]);
```

Facades
-------

[](#facades)

### Distance

[](#distance)

Calculate distance between to coordinates

##### usage

[](#usage)

```
//with coordinates
Distance::from(52.4968, 5.0727)
    ->to(52.5144, 4.9641)
    ->get();

//with cities
Distance::from("Volendam")
    ->to("Purmerend")
    ->get();
```

The get method accepts three params: unit, format,precision

### Flash

[](#flash)

Adds a flash message to the session flash

##### usage

[](#usage-1)

```
//with coordinates
Flash::message('Hello World')
    ->type('success')
    ->duration(3000)
    ->add();
```

The get method accepts three params: unit, format,precision

```
->get(unit:"m"); //distance in meter (default km)
->get(format:true) // 5,4 km
```

Traits
------

[](#traits)

### AddressModelTrait

[](#addressmodeltrait)

#### Required database fields

[](#required-database-fields)

city, street, building, postcode

##### installation

[](#installation)

Add to your model

```
use AddressModelTrait;
```

This will trigger an attribute setter and getter.

##### Usage

[](#usage-2)

```
$model->address->street;
```

### NameModelTrait

[](#namemodeltrait)

#### Required database fields

[](#required-database-fields-1)

initials, lastname, prefix, own\_lastname, own\_prefix, sex

##### installation

[](#installation-1)

Add to your model

```
use NameModelTrait;
```

This will trigger an attribute setter and getter.

##### Usage

[](#usage-3)

```
$model->name->salutation; // Dhr. / Mevr.
$model->name->name; //Full name
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance80

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~71 days

Recently: every ~10 days

Total

21

Last Release

104d ago

Major Versions

v1.17 → v2.02023-06-14

v2.0.4 → v3.02025-11-17

PHP version history (2 changes)v1.14PHP ^8.1

v2.0.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/84de98c9a1803dbd730aabade43023ab14d7df77a5e71c012ecdd1150b300213?d=identicon)[mmerlijn](/maintainers/mmerlijn)

---

Top Contributors

[![mmerlijn](https://avatars.githubusercontent.com/u/8401393?v=4)](https://github.com/mmerlijn "mmerlijn (37 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/mmerlijn-laravel-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/mmerlijn-laravel-helpers/health.svg)](https://phpackages.com/packages/mmerlijn-laravel-helpers)
```

###  Alternatives

[crankycyclops/m2-module-discount-code-url

Allows discount codes to be applied to a browser session automatically via a query string or URL path.

4112.3k](/packages/crankycyclops-m2-module-discount-code-url)[fritzmg/contao-news-related

Simple Contao 4+ bundle for setting related news directly.

113.8k](/packages/fritzmg-contao-news-related)[terabin/flarum-ext-sitemap

Generate a Sitemap for Flarum automatically

103.0k1](/packages/terabin-flarum-ext-sitemap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
