Skip to content

Instantly share code, notes, and snippets.

View hernandev's full-sized avatar

Diego Hernandes hernandev

View GitHub Profile
class Foo extends Eloquent {
protected $table = 'foo';
public function Bar()
return $this->belongsTo('Bar');
class Foo extends Eloquent {
protected $table = 'foo';
public function Bar()
// Notice the bar class name now is lowercase
return $this->belongsTo('bar');
echo "Laravel Brasil";

My Validation Base Class

I was asked how I deal with validation / create and update validation rulesets. Well here is one method I have used. Don't be afraid to build on top of what the framework has already given you. In my projects I use a base class for almost anything. You never know when you want your classes to inherit some common functionality. My BaseValidator actually has some pretty useful methods and properties in it.


namespace FooProject\Internal\Validators;

use FooProject\Internal\Sanitizers\BaseSanitizer;
hernandev / CODECASTS.icls
Last active August 29, 2015 14:23
<scheme name="CODECASTS" version="141" parent_scheme="Darcula">
<option name="LINE_SPACING" value="1.2" />
<option name="EDITOR_FONT_SIZE" value="16" />
<option name="CONSOLE_FONT_NAME" value="Menlo" />
<option name="CONSOLE_FONT_SIZE" value="14" />
<option name="EDITOR_FONT_NAME" value="Menlo" />
<option name="GUTTER_BACKGROUND" value="2b2b2b" />
<option name="LINE_NUMBERS_COLOR" value="3c3c3c" />
<option name="TEARLINE_COLOR" value="3c3c3c" />
hernandev / start.php
Created December 15, 2013 19:00
Ambientes do Laravel 4.1 por domínio
// Inicio do arquivo omitido
* Detectar domínio no Laravel 4.1 e aplicar o ambiente correspondente
$env = $app->detectEnvironment(function(){
# Mysql 5.7
image: ambientum/mysql:5.7
container_name: sandbox-mysql
- sandbox-mysql:/var/lib/mysql
- "3306:3306"
namespace App;
use Illuminate\Database\Eloquent\Model;
class MeuModel extends Model
protected $dates = [
# segunda versão da sintaxe do docker-compose
version: '2'
# volumes para dados persistentes
# persistiremos os dados do MySQL
driver: local
# persistiremos os dados do Redis
namespace Codecasts\Core\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class RedirectIfWrongUrlOrProtocol
/** @var Request */