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
/* In My Controller */ | |
public function processRegister() { | |
$validator = Validator::make(Input::all(), User::$baseValidationRules); // Create validation | |
if ($validator->fails()) { | |
Session::flashInput(Input::all()); // Save the user input for one request | |
return Redirect::to('register')->withErrors($validator); // Send them back to registration with validation errors | |
} | |
if ((new User)->createFromInput()) { | |
Session::flash('successMessage', 'Your account has been created! You can log in now'); |
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
class Setting extends Eloquent { | |
protected $guarded = array('id'); | |
protected $fillable = array('name', 'value'); | |
public static function setValue($name, $value) { | |
$setting = self::firstOrCreate(['name' => $name]); // Error happens here | |
$setting->value = $value; | |
return $setting->save() ? $setting : false; | |
} | |
} |
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
/* Setting Model */ | |
class Setting extends Eloquent { | |
public function setValue($name, $value) { | |
$setting = $this->firstOrCreate(array('name' => $name)); | |
$setting->value = $value; | |
return $setting->save() ? $setting : false; | |
} | |
} | |
/* Controller */ |
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
/** | |
* Get a unique mailbox address | |
* @return string | |
*/ | |
public function getUniqueAddress() { | |
do { | |
$address = Mailbox::createRandomAddress(); | |
$existingAddress = Mailbox::where('address', 'LIKE', $address)->first(); | |
} while ($existingAddress); | |
return $address; |
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
use Illuminate\Validation\Validator; | |
class CustomValidationRules extends Validator | |
{ | |
protected function validateMultiExists($attribute, $value, $parameters) | |
{ | |
if (!is_array($value)) return false; | |
foreach ($value as $submitValue) | |
{ |
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
angular.module('myApp', []) | |
.config(function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) { | |
$httpProvider.interceptors.push('authInterceptor'); | |
}) | |
.factory('authInterceptor', function ($rootScope, $q, $cookieStore, $location, localStorageService) { | |
return { | |
// Add authorization token to headers | |
request: function (config) { | |
config.headers = config.headers || {}; |
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
angular.module('myApp', []) | |
.run(function ($rootScope, $location, Auth) { | |
//Redirect to login if route requires auth and you're not logged in | |
$rootScope.$on('$stateChangeStart', function (event, next) { | |
Auth.isLoggedIn().then(function(loggedIn) { | |
if (next.authenticate && !loggedIn) { | |
$location.path('/login'); | |
} | |
}); | |
}); |
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
exports.show = function(req, res) { | |
var query = {}; | |
if (typeof req.query.name !== 'undefined') { | |
query.name = req.params.id; | |
} else { | |
query._id = req.params.id; | |
} | |
Channel.findOne(query, function (err, channel) { | |
if(err) { return handleError(res, err); } |
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
freelance | |
remote | |
http://hnhiring.me/ | |
https://github.com/lukasz-madon/awesome-remote-job/ | |
http://www.lancelist.com/ | |
https://gun.io/dash/ | |
http://www.10xmanagement.com/ | |
https://theworkmob.com/ | |
http://workingnotworking.com | |
https://authenticjobs.com |
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
proxy_pass http://localhost:3000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade \$http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host \$host; |
OlderNewer