PHP code example of conedevelopment / blade-filters
1. Go to this page and download the library: Download conedevelopment/blade-filters 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/ */
conedevelopment / blade-filters example snippets
{{ 'john' | ucfirst }} // John
{{ 'john' | ucfirst | substr:0,1 }} // J
{{ '1999-12-31' | date:'Y/m/d' }} // 1999/12/31
{{ $name | ucfirst | substr:0,1 }}
{{ $user['name'] | ucfirst | substr:0,1 }}
{{ $currentUser->name | ucfirst | substr:0,1 }}
{{ getName() | ucfirst | substr:0,1 }}
$currency = 'HUF'
{{ '12.75' | currency:$currency }} // HUF 12.75
{{ 'This is a title' | slug }} // this-is-a-title
{{ 'This is a title' | title }} // This Is A Title
{{ 'foo_bar' | studly }} // FooBar
{{ ('a' | 'b') | upper }} // C
{{ '17.99' | currency:'CHF' }} // CHF 17.99
{{ '17.99' | currency:'€',false }} // 17.99 €
{{ '1999/12/31' | date }} // 1999-12-31
{{ '1999/12/31' | date:'F j, Y' }} // December 31, 1999
{{ 'Árpamaláta' | lcfirst }} // árpamaláta
{{ 'ABCDEF' | reverse }} //FEDCBA
{{ 'My name is' | substr:0,2 }} // My
{{ 'My name is' | substr:3 }} // name is
{{ ' trim me ' | trim }} // trim me
{{ 'árpamaláta' | ucfirst }} // Árpamaláta
BladeFilters::macro('filterName', function ($value, $param1 = 'default', $param2 = null) {
return ...;
});
{{ 'string' | filterName:1,2 }}
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
BladeFilters::macro('substr', function ($value, $start, $length = null) {
return mb_substr($value, $start, $length);
});
}
}