tanthammar/laravel-extras

Custom validation rules for the Laravel Framework

2.1.1 2024-04-02 09:37 UTC

This package is auto-updated.

Last update: 2024-05-02 09:54:31 UTC


README

Requirements

  • PHP 8.1
  • Laravel v9.0

Installation

composer require tanthammar/laravel-extras

Helpers

See src/...

Macros

See src/LaravelExtrasServiceProvider.php

Examples

Convert markdown in translation strings to html for blade files

//Filament placeholder field with translation string containing Markdown tags

Placeholder::make(trans('fields.accounting-chart'))
    ->disableLabel()
    ->content(new MarkdownToHtmlString(__('fields.account_hint')))
    ->columnSpan('full')

Swap the order/sorting of an array, like swap the 3rd row with the 1st. the 1st will become the 3rd.

$assocArray = [
    'item_one'   => ['name' => 'One'],
    'item_two'   => ['name' => 'Two'],
    'item_three' => ['name' => 'Three'],
    'item_four'  => ['name' => 'Four'],
];
 
$newArray = Arr::swap($array, 'item_one', 'item_three');
 
/*
 * [
 *     'item_three' => ['name' => 'Three'],
 *     'item_two'   => ['name' => 'Two'],
 *     'item_one'   => ['name' => 'One'],
 *     'item_four'  => ['name' => 'Four'],
 * ]
 */

Documentation

There won't be much documentation written, this repository will grow as I add items. The source code should contain enough hints to be self-explanatory.