PHP code example of internetguru / laravel-common

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

    

internetguru / laravel-common example snippets


    use Illuminate\Support\Facades\Facade;

    'aliases' => Facade::defaultAliases()->merge([
        'Helpers' => InternetGuru\LaravelCommon\Support\Helpers::class,
    ])->toArray(),
    

use Carbon\Carbon;
use Illuminate\Support\Facades\Number;

Number::useCurrency('USD'); // Set the default currency
echo Number::currencyForHumans(1234);
// Output (en_US locale): $1,234
echo Number::currencyForHumans();
// Output (en_US locale): $
echo Number::currencyForHumans(1234.567, in: 'EUR', precision: 2);
// Output (en_US locale): €1,234.57
app()->setLocale('cs_CZ'); // Set the locale to Czech
echo Number::currencyForHumans(1234.567, in: 'EUR', precision: 2);
// Output (cs_CZ locale): 1 234,57 €

$date = Carbon::parse('2023-12-31');
echo $date->dateForHumans();
// Output (en_US locale): 12/31/2023
$dateTime = Carbon::parse('2023-12-31 18:30:00');
echo $dateTime->dateTimeForHumans();
// Output (en_US locale): 12/31/2023 6:30 PM

   $middleware->group('web', [
         // ...
         \InternetGuru\LaravelCommon\Middleware\CheckPostItemNames::class,
    ]);
   

use Illuminate\Support\ServiceProvider;

'providers' => ServiceProvider::defaultProviders()->replace([
    Illuminate\Translation\TranslationServiceProvider::class => InternetGuru\LaravelCommon\TranslationServiceProvider::class,
])->toArray(),

use Illuminate\Database\Eloquent\Model;
use InternetGuru\LaravelCommon\Casts\CarbonIntervalCast;

class Task extends Model
{
    protected $casts = [
        'duration' => CarbonIntervalCast::class,
    ];
}

    
    Route::get('/', function () {
        // ...
    })->name('home');

    Route::get('/products', function () {
        // ...
    })->name('products.index');

    Route::get('/products/{product}', function ($product) {
        // ...
    })->name('products.show');
    

    
    return [
        'home' => 'Long Application Name|LAN',
        'products.index' => 'All Products|Products',
        'products.show' => 'Product Details',
    ];