protected static function boot() { parent::boot(); static::creating(function ($model) { $model->{$model->getKeyName()} = (string) Uuid::uuid4(); }); }
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); }); }
/** * @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; }