PHP code example of padosoft / laravel-support

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

    

padosoft / laravel-support example snippets

 php
echo validate('192.168.0.1', 'ip'); //true
echo validate('dfdsfdsfs', 'ip'); //false
echo validate('20150230', 'date'); //false
echo validate('20150227', 'date'); //true
 php
echo locale();  //'en'
this->app->setLocale('it');
echo locale(); 'it'
 php
$query = 'update "users" set "remember_token" = ? where "id" = ?';
$bindings = [
    0 => "dfsf234wdfsafsdfsdf",
    1 => "1"
];
$result = query_interpolate($query, $bindings);
echo $result; //update "users" set "remember_token" = 'dfsf234wdfsafsdfsdf' where "id" = 1
 php
[
  "query" => "select * from `negozi` where `id` = ?",
  "bindings" => [343242342,],
  "time" => 1.77,
  "look" => "select * from `negozi` where `id` = 343242342",
]
 php
//If you want to print interpolated queries and relative time
foreach ($queries as $query) {
    echo 'e($query['look']) . "\t" . e($query['time']) . PHP_EOL;
}

//For performance and memory reasons, after get queries info, you can disable query log by excecute
\DB::disableQueryLog();
//or in case of more db connections:
\DB::connection('my_connection')->disableQueryLog();
 php
\DB::enableQueryLog();
User::first();
User::first();
User::first();
echo query_table();//print html table with queries
\DB::disableQueryLog();
 php
echo current_user(); //false
$user = User::first();
Auth::login($user);
var_dump(current_user()); //sump current logged user
echo current_user('id'); //1
echo current_user('email'); //[email protected]