Created
September 23, 2015 12:06
-
-
Save 4lun/e2868654458f980cc168 to your computer and use it in GitHub Desktop.
Laravel 5.1 Base Model - adds defaults to $casts property on __construct
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 | |
namespace App; | |
use Illuminate\Database\Eloquent\Model as Eloquent; | |
class Model extends Eloquent | |
{ | |
/** | |
* Create a new Eloquent model instance. | |
* | |
* @param array $attributes | |
*/ | |
public function __construct(array $attributes = []) | |
{ | |
$this->casts = array_merge([ | |
'id' => 'integer', | |
'user_id' => 'integer', | |
], $this->casts); | |
parent::__construct($attributes); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment