PHP code example of crthiago / laravel-helpers

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

    

crthiago / laravel-helpers example snippets


money('0.5'); // R$ 0,50
money('1000', false); // 1.000,00
money(1.5, '$ ', 2, '.', ''); // $ 1.50
-----
number_db('1.000'); // 1000
number_db('1.000,5'); // 1000.5
number_db('R$ 1.000,50'); // 1000.5
-----
format_date('2018-02-01'); // '01/02/2018'
format_date('2018-02-01', 'm/d/Y'); // '02/01/2018'
-----
datetime('2018-02-01 12:00:00');  // '01/02/2018 12:00:00'
-----
date_db('01/02/2018'); // '2018-02-01'
date_db('12/31/2018', 'm/d/Y') // '2018-12-31'
-----
datetime_db('01/02/2018 12:30:00'); // '2018-02-01 12:30:00'

mask_cpf('12345678900'); // '123.456.789-00'
mask_cpf(12); // '000.000.000-12'
mask_cpf('cpf: 023.456.789-00'); // '023.456.789-00'
-----
mask_cnpj(12345678000190); // '12.345.678/0001-90'
-----
mask_phone('12345678901'); // '(12) 34567-8901'
mask_phone(1234567890); // '(12) 3456-7890'
mask_phone('phone: (12) 34567-8901'); // '(12) 34567-8901'
-----
mask_cep('12345678'); // '12345-678'
-----
mask_custom(12345678900, '###.###.###-##'); // '123.456.789-00'

remove_accents('áàãâä'); // 'aaaaa'
-----
remove_special_characters('abc123!@#$%&*()áàãâäéèêëíìîïóòõôöúùûüç'); // 'abc123'

validate_cpf(3488506037); // true
validate_cpf('034.885.060-37'); // true
validate_cpf('12345678901'); // false
-----
validate_cnpj('29.848.999/0001-05'); // true
validate_cnpj('12345678901234'); // false
bash
  php artisan vendor:publish --provider="Crthiago\LaravelHelpers\LaravelHelpersServiceProvider"