Skip to content

Instantly share code, notes, and snippets.

View hernandev's full-sized avatar

Diego Hernandes hernandev

View GitHub Profile
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class MeuModel extends Model
{
protected $dates = [
'expires_at',
'outro_campo_do_tipo_timestamp',
];
}
# Mysql 5.7
mysql:
image: ambientum/mysql:5.7
container_name: sandbox-mysql
volumes:
- sandbox-mysql:/var/lib/mysql
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=sandbox
@hernandev
hernandev / CODECASTS.icls
Last active August 29, 2015 14:23
CODECATS.icls
<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" />
<colors>
<option name="GUTTER_BACKGROUND" value="2b2b2b" />
<option name="LINE_NUMBERS_COLOR" value="3c3c3c" />
<option name="TEARLINE_COLOR" value="3c3c3c" />

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.

<?php

namespace FooProject\Internal\Validators;

use FooProject\Internal\Sanitizers\BaseSanitizer;
<?php
echo "Laravel Brasil";
?>
<?php
class Foo extends Eloquent {
protected $table = 'foo';
public function Bar()
{
// Notice the bar class name now is lowercase
return $this->belongsTo('bar');
<?php
class Foo extends Eloquent {
protected $table = 'foo';
public function Bar()
{
return $this->belongsTo('Bar');
}
@hernandev
hernandev / start.php
Created December 15, 2013 19:00
Ambientes do Laravel 4.1 por domínio
<?php
// Inicio do arquivo omitido
/*
* Detectar domínio no Laravel 4.1 e aplicar o ambiente correspondente
*/
$env = $app->detectEnvironment(function(){