コード例 #1
0
ファイル: UuidEntity.php プロジェクト: gez-studio/gez-mall
 protected static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->{$model->getKeyName()} = (string) Uuid::uuid4();
     });
 }
コード例 #2
0
ファイル: Entity.php プロジェクト: gez-studio/gez-mall
 public function scopeWhereMorphNot(Builder $query, $morphName, Entity $morphEntity)
 {
     $query->where(function (Builder $query) use($morphName, $morphEntity) {
         $query->where($morphName . '_type', '<>', $morphEntity->getMorphClass())->orWhere($morphName . '_id', '<>', $morphEntity->id);
     });
 }
コード例 #3
0
 /**
  * @param $morphName
  * @param Entity $morphEntity
  * @return $this
  */
 public function whereMorph($morphName, Entity $morphEntity)
 {
     $this->where($morphName . '_type', '=', $morphEntity->getMorphClass());
     $this->where($morphName . '_id', '=', $morphEntity->id);
     return $this;
 }