本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::performInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::performInsert方法的具体用法?PHP Model::performInsert怎么用?PHP Model::performInsert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::performInsert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performInsert
/**
* (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: performInsert
/**
*
*/
protected function performInsert(\Illuminate\Database\Eloquent\Builder $query, array $options)
{
$this->attributes['uid'] = md5(uniqid(mt_rand(), true));
parent::performInsert($query, $options);
}
示例3: performInsert
/**
* 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: performInsert
/**
* @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: performInsert
/** 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;
}