PHP code example of mercuryseries / laravel-helpers

1. Go to this page and download the library: Download mercuryseries/laravel-helpers 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/ */

    

mercuryseries / laravel-helpers example snippets


MercurySeries\Helpers\HelpersServiceProvider::class,



// File: app/Helpers/BooksHelper.php

namespace App\Helpers;

use App\Book;

class BooksHelper
{
    public static function formatPrice(Book $book)
    {
        if($book->isFree()) {
            return '<strong>Free!</strong>';
        } else {
            return sprintf('$%f', number_format($book->price, 2, '.', ''));
        }
    }
}



// File: app/Helpers/PagesHelper.php

namespace App\Helpers;

class PagesHelper
{
    public static function setActive($route)
    {
        // your code goes here
    }
}

{{ $formatPrice($book) }}
{{ $setActive('home') }}

{{ App\Helpers\BooksHelper::formatPrice($book) }}
config/app.php

php artisan vendor:publish --provider="MercurySeries\Helpers\HelpersServiceProvider"