PHP code example of riipandi / laravel-helpers

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

    

riipandi / laravel-helpers example snippets


chain(new SomeClass)
    ->firstMethod()
    ->secondMethod()
    ->thirdMethod();

// You can use the "carry" constant to pass the result of one method into the other:
chain(new Str)->singular('cars')->ucfirst(carry)();
// Returns "Car"
// Also, you can grab the result of the chain by trailing
// a "()" on the end of it. (Thanks to Taylor Otwell for these two additions)

$tenantPostIds = connection('tenantdb', function () {
    return Post::pluck('id');
});

dump_sql(\DB::table('users')->where('email', "blaBla")->where('id', 1));
// returns "select * from `users` where `email` = 'blaBla' and `id` = 1"

user()->posts()->create([...]);

echo money(12); // echoes "$12.00"
echo money(12.75); // echoes "$12.75"
echo money(12.75, false); // echos "$13"
echo money(12.75, true, 'en_GB'); // echos "£12.75"
// Note: unless specified otherwise, money() will detect the current locale.

stopwatch(function () {
    sleep(2);
}); // returns "2.0"

str_between('--thing--', '--'); // returns "thing"
str_between('[thing]', '[', ']'); // returns "thing"

Str::between('--thing--', '--'); // returns "thing"
Str::between('[thing]', '[', ']'); // returns "thing"


str_extract('Jan-01-2019', '/Jan-(.*)-2019/'); // returns "01"

Str::extract('Jan-01-2019', '/Jan-(.*)-2019/'); // returns "01"



str_match('Jan-01-2019', '/Jan-.*-2019/'); // returns true
str_match('foo bar baz', 'bar'); // returns true

Str::match('Jan-1-2019', '/Jan-(.*)-2019/'); // returns true


str_validate('[email protected]', 'regex:/\.net$/|email|max:10');
// returns: ["Format is invalid.", "May not be greater than 10 characters."]

Str::validate('[email protected]', 'regex:/\.net$/|email|max:10');
// returns: ["Format is invalid.", "May not be greater than 10 characters."]

str_wrap('thing', '--'); // returns "--thing--"

Str::wrap('thing', '--'); // returns "--thing--"

$startDate = '2040-01-01';
$endDate = '2020-01-01';

if ($endDate < $startDate) {
    swap($startDate, $endDate);
}

echo $startDate; // prints "2020-01-01"
echo $endDate; // prints "2040-01-01"

$somethingYouWantToDebug = new StdClass;
tinker($somethingYouWantToDebug);
 php
carbon('One year ago');
 php
faker()->address; // returns random, fake address
faker('address'); // alternate syntax