예제 #1
0
파일: Base.php 프로젝트: Nebo15/gandalf.api
 /**
  * @param array $options
  * @return $this
  */
 public function save(array $options = [])
 {
     if (parent::save($options)) {
         return $this;
     }
     throw new FailedToSaveModel();
 }
 /**
  * Applies the given where conditions to the model.
  *
  * @param array $where
  * @return void
  */
 protected function applyConditions(array $where)
 {
     foreach ($where as $field => $value) {
         if (is_array($value)) {
             list($field, $condition, $val) = $value;
             $this->model = $this->model->where($field, $condition, $val);
         } else {
             $this->model = $this->model->where($field, '=', $value);
         }
     }
 }
예제 #3
0
 public function save(array $options = array())
 {
     if (stripos($this->first_name, " ") !== false && empty($this->middle_name)) {
         $p = explode(" ", $this->first_name);
         if (count($p) == 2) {
             $this->first_name = $p[0];
             $this->middle_name = $p[1];
         } else {
             $this->first_name = array_shift($p);
             $this->middle_name = implode(" ", $p);
         }
     }
     if (strlen($this->middle_name) == 1) {
         $this->middle_name = $this->middle_name . '.';
     }
     $this->setAliases();
     $this->setDivision();
     $this->setPhoto();
     parent::save();
 }
예제 #4
0
파일: Role.php 프로젝트: winponta/cani
 /**
  * Create a new Eloquent model instance.
  *
  * @param array $attributes
  */
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes);
     $this->setTable(config('cani.collections.roles'));
 }
 /**
  * Bootstrap the application events.
  */
 public function boot()
 {
     Model::setConnectionResolver($this->app['db']);
     Model::setEventDispatcher($this->app['events']);
 }