PHP code example of protonemedia / laravel-mixins

1. Go to this page and download the library: Download protonemedia/laravel-mixins library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

protonemedia / laravel-mixins example snippets


ProtoneMedia\LaravelMixins\Blade\DecimalMoneyFormatter::directive();

ProtoneMedia\LaravelMixins\Blade\DecimalMoneyFormatter::directive('decimals', 'EUR');

ProtoneMedia\LaravelMixins\Blade\IntlMoneyFormatter::directive();

ProtoneMedia\LaravelMixins\Blade\IntlMoneyFormatter::directive('money', 'EUR', 'nl_NL');

ProtoneMedia\LaravelMixins\Commands\GenerateSitemap::register();

ProtoneMedia\LaravelMixins\Commands\GenerateSitemap::register('generate-sitemap');

$rule = new ProtoneMedia\LaravelMixins\Rules\CurrentPassword;

use ProtoneMedia\LaravelMixins\Rules\DimensionsWithMargin;

$rule = DimensionsWithMargin::make()->ratio(20 / 9)->margin(1),

use ProtoneMedia\LaravelMixins\Rules\Host;

$rule = Host::make(['facebook.com', 'fb.me']);

use ProtoneMedia\LaravelMixins\Rules\InKeys;

$rule = new InKeys(['laravel' => 'Laravel Framework', 'tailwindcss' => 'Tailwind CSS framework']);

// same as

use Illuminate\Validation\Rules\In;

$rule = new In(['laravel', 'tailwindcss']);

use ProtoneMedia\LaravelMixins\Rules\MaxWords;

$rule = MaxWords::make(250);

$rule = new ProtoneMedia\LaravelMixins\Rules\UrlWithoutScheme;

Str::mixin(new ProtoneMedia\LaravelMixins\String\Compact);

$string = "Hoe simpeler hoe beter. Want hoe minder keuze je een speler laat, hoe groter de kans dat hij het juiste doet.";

// Hoe simpeler hoe beter. Want hoe ... de kans dat hij het juiste doet.
echo Str::compact($string);

// Hoe simpeler hoe - het juiste doet.
echo Str::compact($string, 16, ' - ');

Str::mixin(new ProtoneMedia\LaravelMixins\String\HumanFilesize);

$size = 3456789;

// '3.3 MB'
Str::humanFilesize($size));

Str::mixin(new ProtoneMedia\LaravelMixins\String\Text);

$html = "<h1>Protone Media</h1>";

// Protone Media
Str::text($html);

Str::mixin(new ProtoneMedia\LaravelMixins\String\Url);

$url = "protone.media";

// https://protone.media
Str::url($url);

Str::mixin(new ProtoneMedia\LaravelMixins\String\SecondsToTime);

Str::secondsToTime(10); // 00:10
Str::secondsToTime(580); // 09:40
Str::secondsToTime(3610); // 01:00:10

// force 'hh:mm:ss' format, even under an hour:
Str::secondsToTime(580, false); // 00:09:40

$ghostscript = new ProtoneMedia\LaravelMixins\Pdf\Ghostscript;

$regeneratedPdf = $ghostscript->regeneratePdf(
    file_get_contents('/uploads/invoice.pdf')
);

$ghostscript = new Ghostscript('gs-binary');

use Illuminate\Foundation\Http\FormRequest;
use ProtoneMedia\LaravelMixins\Request\ConvertsBase64ToFiles;

class ImageRequest extends FormRequest
{
    use ConvertsBase64ToFiles;

    protected function base64FileKeys(): array
    {
        return [
            'jpg_image' => 'Logo.jpg',
        ];
    }

    public function rules()
    {
        return [
            'jpg_image' => ['

$jpgFile = $request->file('jpg_image');

// Logo.jpg
$jpgFile->getClientOriginalName();

class ImageRequest extends FormRequest
{
    use ConvertsBase64ToFiles;

    protected function base64FileKeys(): array
    {
        return [
            'company.logo' => 'Logo.jpg',
            'user' => [
                'avatar' => 'Avatar.jpg',
            ],
        ];
    }
}
bash
php artisan sitemap:generate