This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT if( TIMEDIFF('2014-12-11 11:00:00','2014-12-11 11:39:30') < 0, 'older','newer') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dd(DB::getQueryLog()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Generates a string of random bytes of the provided number (7 in the example below) and then converts that binary to hexadecimal | |
// The hexadecimal conversion doubles the string size so the final result in the example below will be 14 characters long. | |
echo bin2hex(openssl_random_pseudo_bytes(7)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure to use the decimal fraction of a second in the examples below | |
// Came across issues in Safari when they weren't used, see http://www.w3.org/TR/NOTE-datetime for more info | |
// September 10th 2014, 5pm GMT | |
new Date('2014-09-10T17:00:00.000').getTime() | |
// September 10th 2014, 5pm ET | |
new Date('2014-09-10T17:00:00.000-04:00').getTime() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App::error(function(\Illuminate\Session\TokenMismatchException $exception) | |
{ | |
return Redirect::back()->withErrors('Your session has expired. Please try again.'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return an error if $value was found in a record from today | |
Validator::extend('unique_today', function($attribute, $value, $parameters) { | |
if ( $this->findAll( null, array( $attribute => $value, 'from' => date('Y-m-d') ) )->count() ) { | |
return false; | |
} | |
return true; | |
}); | |
Validator::replacer('unique_today', function($message, $attribute, $rule, $parameters) { | |
return Lang::get('error_enteredtoday', array('attribute' => $attribute)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return an error if $value day is today | |
Validator::extend('before_today', function($attribute, $value, $parameters) { | |
if ( strtotime( $value ) >= strtotime( date("Y-m-d") ) ) { | |
return false; | |
} | |
return true; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dd(DB::getQueryLog()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$env = $app->detectEnvironment(function(){ | |
// For artisan commands, default to localhost | |
$serverName = 'localhost'; | |
if ( isset($_SERVER["SERVER_NAME"]) && strlen($_SERVER["SERVER_NAME"]) > 0 ){ | |
$serverName = $_SERVER["SERVER_NAME"]; | |
} | |
// List of environments with the server name as the key | |
$serverNames = array( | |
'staging.net' => 'staging', | |
'productionserver.com' => 'production' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* IP Address Match | |
* | |
* Takes an $ipAddress as a string and an array of IP Addresses and/or IP wildcards $toMatch it with, returns boolean | |
* true if a match is found and false otherwise | |
* | |
* @param string $ipAddress | |
* @param array $toMatch |
NewerOlder