performInsert() protected method

Perform a model insert operation.
protected performInsert ( Builder $query ) : boolean
$query Builder
return boolean
コード例 #1
0
 /**
  * (non-PHPdoc)
  * @see \Illuminate\Database\Eloquent\Model::performInsert()
  */
 public function performInsert(Builder $query, array $options = [])
 {
     if (!Auth::user() instanceof User) {
         App::error(function (InvalidUserException $exception) {
             Log::error($exception);
             return 'Access denid for creating a new ' . get_called_class();
         });
     }
     $this->attributes['active'] = 1;
     $this->attributes[self::CREATED_AT] = new \DateTime('now', new \DateTimeZone(env('APP_TIMEZONE', 'UTC')));
     $this->attributes[self::CREATED_BY] = Auth::user()->id;
     $this->attributes[self::UPDATED_AT] = new \DateTime('now', new \DateTimeZone(env('APP_TIMEZONE', 'UTC')));
     $this->attributes[self::UPDATED_BY] = Auth::user()->id;
     return parent::performInsert($query, $options);
 }
コード例 #2
0
ファイル: ProductCategory.php プロジェクト: subbly/cms
 /**
  *
  */
 protected function performInsert(\Illuminate\Database\Eloquent\Builder $query, array $options)
 {
     $this->attributes['uid'] = md5(uniqid(mt_rand(), true));
     parent::performInsert($query, $options);
 }
コード例 #3
0
 /**
  * Perform a model insert operation.
  *
  * @param  EloquentBuilder $query
  * @param  array $options
  *
  * @return bool
  */
 protected function performInsert(EloquentBuilder $query, array $options = [])
 {
     if ($this->isMoved === false) {
         $this->position = $this->position !== null ? $this->position : $this->getNextAfterLastPosition();
         $this->real_depth = $this->getNewRealDepth($this->parent_id);
     }
     return parent::performInsert($query, $options);
 }
コード例 #4
0
 /**
  * @param OriginBuilder $query   Illuminate database eloquent buildere
  * @param array         $options options
  * @return bool
  */
 protected function performInsert(OriginBuilder $query, array $options = [])
 {
     if ($this->incrementing !== true && is_null($this->{$this->getKeyName()}) === true) {
         $this->{$this->getKeyName()} = $this->getKeyGen()->generate();
     }
     return parent::performInsert($query, $options);
     // TODO: Change the autogenerated stub
 }
コード例 #5
0
ファイル: PkModel.php プロジェクト: pkirkaas/PkExtensions
 /** This is just to enable a postCreate() method subclasses can implement
  * to take particular action after a new instance has been created and saved
  * <P>
  * <b><tt>performInsert</tt></b> is only called from Model::save() - 
  * So every insert will also involve a save, but not every save involves an
  * insert - SO ANYTHING THAT INVOKES postCreate() WILL ALSO CALL postSave()!
  * Put another way, postSave() will aslo be called on create, so you can put it all in there...
  * @param Builder $query
  * @param array $options
  * @return type
  */
 protected function performInsert(Builder $query, array $options = [])
 {
     $result = parent::performInsert($query, $options);
     if ($result === true) {
         $this->postCreate($options);
     }
     return $result;
 }