You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.
According to the following document, we need to register our entities.I have no idea why we are doing this.
// Push your entity fully qualified namespace
app('rinvex.attributes.entities')->push(\Path\To\Your\Entity::class);
// Or push the morph class alias if any
app('rinvex.attributes.entities')->push('entity');
I found that even the model does not exist, also we could insert the record.
For example, I don't have App\Models\Company, but with the following code, I still can get a record of the company.
When we get entity attributes, it will check if it is a valid entity.
public function getEntityAttributes(): Collection
{
$morphClass = $this->getMorphClass();
static::$entityAttributes = static::$entityAttributes ?? collect();
if (! static::$entityAttributes->has($morphClass) && Schema::hasTable(config('rinvex.attributes.tables.attribute_entity'))) {
$locale = app()->getLocale();
/* This is a trial to implement per resource attributes,
it's working but I don't like current implementation.
$routeParam = request()->route($morphClass);
// @TODO: This is REALLY REALLY BAD DESIGN!! But can't figure out a better way for now!!
// Refactor required, we need to catch `$this` itself, we should NOT use request and routes here!!
// But still at this very early stage, `$this` still not bound to model's data, so it's just empty object!
$entityId = $routeParam && collect(class_uses_recursive(static::class))->contains(HashidsTrait::class) && ! is_numeric($routeParam)
? optional(Hashids::decode($routeParam))[0] : $routeParam;
$attributes = app('rinvex.attributes.attribute_entity')->where('entity_type', $morphClass)->where('entity_id', $entityId)->get()->pluck('attribute_id');
*/
$attributes = app('rinvex.attributes.attribute_entity')->where('entity_type', $morphClass)->get()->pluck('attribute_id');
static::$entityAttributes->put($morphClass, app('rinvex.attributes.attribute')->whereIn('id', $attributes)->orderBy('sort_order', 'ASC')->orderBy("name->\${$locale}", 'ASC')->get()->keyBy('slug'));
}
return static::$entityAttributes->get($morphClass) ?? new Collection();
}
According to the following document, we need to register our entities.I have no idea why we are doing this.
I found that even the model does not exist, also we could insert the record.
For example, I don't have
App\Models\Company
, but with the following code, I still can get a record of the company.The text was updated successfully, but these errors were encountered: