get item relations
This commit is contained in:
@ -42,4 +42,20 @@ class Tag extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public static function getTagListByEntity(string $entity): array
|
||||
{
|
||||
return self::where("entity", $entity)->get()->toArray();
|
||||
}
|
||||
|
||||
public static function getTagLabelByEntity(string $entity): array
|
||||
{
|
||||
$result = [];
|
||||
$tags = self::getTagListByEntity($entity);
|
||||
foreach ($tags as $tag){
|
||||
$result[$tag['id']] = $tag['label'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -24,4 +24,9 @@ class TagEntity extends Model
|
||||
'entity_id' => 'Идентификатор сущности',
|
||||
];
|
||||
}
|
||||
|
||||
public function tag(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tag::class);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user