PHPackages                             lyre/facet - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. lyre/facet

ActiveLibrary[File &amp; Storage](/categories/file-storage)

lyre/facet
==========

Simple categorization module for complex relationships

1.4.3(1mo ago)03132MITPHPPHP ^8.3

Since May 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/kigathi-chege/lyre-facet)[ Packagist](https://packagist.org/packages/lyre/facet)[ RSS](/packages/lyre-facet/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (3)Versions (23)Used By (2)

Lyre Facet
==========

[](#lyre-facet)

Lyre Facet is a `lyre/lyre` add-on for tagging and organizing records with reusable facets and facet values.

It provides three core models:

- `Facet`: the taxonomy group, such as `Blog Category`, `Task Categories`, or `Subscription Plan Category`
- `FacetValue`: a concrete value inside a facet, such as `Free` or `Main`
- `FacetedEntity`: the polymorphic pivot that links any facetable model to a facet value

How It Works
------------

[](#how-it-works)

### Tagging models

[](#tagging-models)

Any model can become facetable by using `Lyre\Facet\Concerns\HasFacet`.

That trait adds:

- `facetedEntities()` morph-many relation to the pivot table
- `facetValues()` has-many-through relation to attached values
- `attachFacetValues($ids)` helper to replace all current facet assignments

This is how Aspire tags exams, assessments, tasks, subscription plans, and articles.

### Hierarchies

[](#hierarchies)

Both `Facet` and `FacetValue` support optional parent/child hierarchy through `parent_id`.

The package exposes:

- `parent()`
- `children()`
- `ancestors()`
- `descendants()`
- `roots()` scope

Repositories for `Facet` and `FacetValue` use `HasHierarchy`, which powers:

- `GET /api/facets/hierarchy/{facetId?}`
- `GET /api/facetvalues/hierarchy/{facetValueId?}`

`facetvalues/hierarchy` also accepts a `facet` query parameter so clients can scope root values to a specific facet.

### Resource behavior

[](#resource-behavior)

- `Facet` uses `slug` as `ID_COLUMN`
- `FacetValue` uses `slug` as `ID_COLUMN`
- both expose lightweight computed fields such as `parent_name` and `facet_name`
- hierarchy endpoints return nested arrays with a `depth` field

Installation
------------

[](#installation)

```
composer require lyre/facet
```

Publish assets:

```
php artisan vendor:publish --provider="Lyre\Facet\Providers\LyreFacetServiceProvider"
```

If you use Filament, register the plugin:

```
use Lyre\Facet\Filament\Plugins\LyreFacetFilamentPlugin;

$panel->plugins([
    new LyreFacetFilamentPlugin(),
]);
```

Example Usage
-------------

[](#example-usage)

Add the trait to a model:

```
use Lyre\Facet\Concerns\HasFacet;

class Article extends Model
{
    use HasFacet;
}
```

Attach facet values:

```
$article->attachFacetValues([$newsId, $featuredId]);
```

Query tagged models through normal Lyre relation filters:

```
GET /api/articles?relation=facetValues,featured
```

Or scope dynamic section data in `lyre/content` using the `facet` filter, which resolves all values under a named facet and constrains the target model to those values.

Aspire Usage Notes
------------------

[](#aspire-usage-notes)

In Aspire, the package is used for:

- blog article categories
- exam categories
- task categories, including the `Free` task flow
- subscription plan categories, including the `Main` plan flow

Good examples to inspect:

- `app/Models/Assessment.php`
- `app/Models/Exam.php`
- `database/seeders/FacetSeeder.php`
- `database/seeders/TaskSeeder.php`
- `app/Filament/Resources/AssessmentResource.php`
- `app/Filament/Resources/ExamResource.php`

Limits To Keep In Mind
----------------------

[](#limits-to-keep-in-mind)

- `attachFacetValues()` is a replace-all helper, not an additive sync helper
- facet-based filtering depends on models exposing the `facetValues` relation
- hierarchy support is implemented only where the repository explicitly uses `HasHierarchy`

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance93

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~29 days

Total

22

Last Release

36d ago

PHP version history (2 changes)1.0.0PHP ^8.2

1.4.1PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38941486?v=4)[Kigathi](/maintainers/Kigathi)[@kigathi](https://github.com/kigathi)

---

Top Contributors

[![kigathi-chege](https://avatars.githubusercontent.com/u/30687709?v=4)](https://github.com/kigathi-chege "kigathi-chege (26 commits)")

---

Tags

phplaravellaravel 10laravel 11laravel 12libraryfilefilescontentSimplegithubmediacrudpagessectionsresourcesfacetsRelationshipsopen-sourcecategorizationfacetlyre

### Embed Badge

![Health badge](/badges/lyre-facet/health.svg)

```
[![Health](https://phpackages.com/badges/lyre-facet/health.svg)](https://phpackages.com/packages/lyre-facet)
```

###  Alternatives

[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k37.3M83](/packages/aws-aws-sdk-php-laravel)[goodway/laravel-nats

Nats jetstream queue driver with client for Laravel

345.5k](/packages/goodway-laravel-nats)[erlandmuchasaj/laravel-file-uploader

A simple package to help you easily upload files to your laravel project.

139.0k](/packages/erlandmuchasaj-laravel-file-uploader)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
