DB::connection()->setPdo($pdo);
$pdo = DB::connection()->getPdo();
function fnUnichr($i)
{
return iconv('UCS-4LE', 'UTF-8', pack('V', $i));
}
function fnUniord($s)
{
return unpack('V', iconv('UTF-8', 'UCS-4LE', $s))[1];
}
function mb_str_split($sString) {
return preg_split('/(?<!^)(?!$)/u', $sString);
}
if (app()->runningInConsole()) {
// do something
}
use Illuminate\Console\Command;
use Validator;
class NewCommand extends Command
{
protected $description = '';
protected $signature = 'new_command';
public function fnValidate($oMethod, $aRules)
{
$sValue = $oMethod();
$bValidate = $this->fnValidateInput($aRules, $sValue);
if ($bValidate !== true) {
$this->warn($bValidate);
$sValue = $this->fnValidate($oMethod, $aRules);
}
return $sValue;
}
public function fnValidateInput($aRules, $sValue)
{
$oValidator = Validator::make([$aRules[0] => $sValue], [$aRules[0] => $aRules[1]], trans('validation'));
if ($oValidator->fails()) {
$oError = $oValidator->errors();
return $oError->first($aRules[0]);
}else{
return true;
}
}
public function handle()
{
$sParameter = $this->fnValidate(function() {
return $this->ask('Something to ask', false);
}, ['sParameter', 'required|min:10|regex:/[a-zA-Z0-9]+/']);
}
}
Artisan::call('migrate', [ '--force' => true ]);
$random = str_random(40);
function fnRandomString($iLength)
{
$aKeys = array_merge(range(0, 9), range('a', 'z'));
$sKey = "";
for($iIndex=0; $iIndex < $iLength; $iIndex++) {
$sKey .= $aKeys[mt_rand(0, count($aKeys) - 1)];
}
return $sKey;
}
// In namespace use \
try {
} catch(\Exception $oException) {
}
Request::method();
use Illuminate\Http\Request;
class UserController extends Controller
{
public function action(Request $request)
{
//
}
}
// The request function returns the current request instance or obtains an input item:
$request = request();
$value = request('key', $default);
return App::call('App\Http\Controllers\Controller@callAction', ['action', $aParameters]);
$oController = app()->make('Controller');
return $oController->callAction('action', $aParameters);
Route::any(
'{any}',
function ()
{
// TODO
}
)->where('any', '.*');