{ return $this->getKey(); } public function getAuthPassword() { return $this->password; } public function getReminderEmail() { return $this->email; } } TestUser::saving(function ($model) { if ($model->password && $model->isDirty('password')) { $model->password = \Hash::make($model->password); } return true; }); TestUser::validating(function ($model) { $model->getValidator()->sometimes('password', 'min:4', function ($model) { return $model->password && $model->isDirty('password') ? TRUE : FALSE; }); if ($model->name == 'discard') { return FALSE; } }); TestUser::validated(function ($model) { if ($model->name == 'discard2') { return FALSE; } });
/** * @expectedException Exception */ function testBuilderException() { TestUser::buildingQuery(function ($query) { return 'this is bad'; }); TestUser::validating(function ($model) { return true; }); TestUser::validated(function ($model) { return true; }); TestUser::get(); }