PHP code example of bitvalencia / laravel-helpers

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

    

bitvalencia / laravel-helpers example snippets


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

return ok();

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

faker()->address; // returns random, fake address
faker('address'); // alternate syntax

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"
 

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"

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

Str::wrap('thing', '--'); // returns "--thing--"
 php
carbon('1 year ago');
 php
fail_validation('key', 'message');