PHPackages                             danielsundermeier/laravel-model-path - 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. danielsundermeier/laravel-model-path

ActiveLibrary

danielsundermeier/laravel-model-path
====================================

Description.

0.4.1(5y ago)0296MITPHP

Since Oct 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/danielsundermeier/laravel-model-path)[ Packagist](https://packagist.org/packages/danielsundermeier/laravel-model-path)[ RSS](/packages/danielsundermeier-laravel-model-path/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (6)Used By (0)

Laravel Model Path
==================

[](#laravel-model-path)

Laravel Models know their own routes.

```
Model::indexPath(); // index, store

$model->index_path; // index, store
$model->create_path; // create
$model->path; // show, update, delete
$model->edit_path; // edit
```

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

[](#installation)

You may install the package via Composer:

```
composer require danielsundermeier/laravel-model-path

```

Usage
-----

[](#usage)

### Basics

[](#basics)

`routes/web.php`

```
Route::resource('movies', App\Http\Controllers\Movies\MovieController::class);
```

Models must use the trait `HasModelPath` and have a `const ROUTE_NAME`.

`app/Models/Movie.php`

```
use D15r\ModelPath\Traits\HasModelPath;

class Movie extends Model
{
    use HasFactory, HasModelPath;

    const ROUTE_NAME = 'movies';
}
```

```
Movie::indexPath(); // /movies

$movie = Movie::find(1);

$movie->index_path; // /movies
$movie->create_path; // /movies/create
$movie->path; // /movies/1
$movie->edit_path; // /movies/1/edit
```

### Advanced

[](#advanced)

`routes/web.php`

```
Route::resource('{type}/{model}/watched', App\Http\Controllers\Watched\WatchedController::class);
```

`app/Models/Watched.php`

```
use D15r\ModelPath\Traits\HasModelPath;

class Watched extends Model
{
    use HasFactory, HasModelPath;

    const ROUTE_NAME = 'watched';

    public function getRouteParameterAttribute() : array
    {
        return [
            'type' => $this->watchable_type::ROUTE_NAME,
            'model' => $this->watchable_id,
            'watched' => $this->id,
        ];
    }
}
```

```
Watched::indexPath([
    'watchable_type' => Movie::class,
    'watchable_id' => 1
]); // /movies/1/watched

$watched = Watched::find(1);

$watched->index_path; // /movies/1/watched
$watched->create_path; // /movies/1/watched/create
$watched->path; // /movies/1/watched/1
$watched->edit_path; // /movies/1//watched/1/edit
```

Contributing
------------

[](#contributing)

Contributions are what make the open source community such an amazing place to be, learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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 ~33 days

Total

5

Last Release

1891d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f15a17f8383957f1ecbce17b3732287c903358b6491a08d8f517592cc3fe32a?d=identicon)[taces2](/maintainers/taces2)

---

Top Contributors

[![danielsundermeier](https://avatars.githubusercontent.com/u/12516165?v=4)](https://github.com/danielsundermeier "danielsundermeier (8 commits)")

### Embed Badge

![Health badge](/badges/danielsundermeier-laravel-model-path/health.svg)

```
[![Health](https://phpackages.com/badges/danielsundermeier-laravel-model-path/health.svg)](https://phpackages.com/packages/danielsundermeier-laravel-model-path)
```

PHPackages © 2026

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