PHPackages                             gpanos/laravel-morph-alias-attribute - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gpanos/laravel-morph-alias-attribute

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gpanos/laravel-morph-alias-attribute
====================================

Register morph aliases for your laravel models using php 8 attributes

00PHP

Since Oct 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/gpanos/laravel-morph-alias-attribute)[ Packagist](https://packagist.org/packages/gpanos/laravel-morph-alias-attribute)[ RSS](/packages/gpanos-laravel-morph-alias-attribute/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP 8 attribute to register Laravel custom polymorphic types.
=============================================================

[](#php-8-attribute-to-register-laravel-custom-polymorphic-types)

[![tests](https://github.com/gpanos/laravel-morph-alias-attribute/actions/workflows/tests.yml/badge.svg)](https://github.com/gpanos/laravel-morph-alias-attribute/actions/workflows/tests.yml)[![code style](https://github.com/gpanos/laravel-morph-alias-attribute/actions/workflows/code-style.yml/badge.svg)](https://github.com/gpanos/laravel-morph-alias-attribute/actions/workflows/code-style.yml)

Instead of defining [custom polymorphic types](https://laravel.com/docs/8.x/eloquent-relationships#custom-polymorphic-types) inside service providers this package offers an alternative way using php 8 attributes.

Inspired by [spatie/laravel-route-attributes](https://github.com/spatie/laravel-route-attributes)

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

[](#installation)

```
composer require gpanos/laravel-morph-alias-attribute
```

Usage
-----

[](#usage)

To define a morph alias for your model add the `MorphAlias` attribute and pass it your alias.

```
