Skip to content

Instantly share code, notes, and snippets.

@thangngoc89
Forked from tdchien/eloquentStandAlone.php
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thangngoc89/b98d29fc79927d954827 to your computer and use it in GitHub Desktop.
Save thangngoc89/b98d29fc79927d954827 to your computer and use it in GitHub Desktop.
// Test Model
<?php
use Illuminate\Database\Eloquent\Model as Eloquent;
class Test extends Eloquent {
protected $table = 'test';
protected $hidden = array();
protected $fillable = array('id', 'title');
protected $nullable = [];
public $timestamps = false;
public static function boot() {
parent::boot();
parent::setEventDispatcher(new Dispatcher());
static::creating(function($test){
write_log('model event creating', 'model_event');
});
}
}
// Test Controller
//$test = Test::create(['title' => 'test']);
//$test = Test::insert(['title' => 'test']);
$test = new Test;
$test->title = 'test';
$test->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment