PHPackages                             michielkempen/laravel-morphable - 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. michielkempen/laravel-morphable

ActiveLibrary

michielkempen/laravel-morphable
===============================

1.2.0(5y ago)2539MITPHPPHP ^7.4|^8.0CI failing

Since Sep 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/michielkempen/laravel-morphable)[ Packagist](https://packagist.org/packages/michielkempen/laravel-morphable)[ Docs](https://github.com/michielkempen/laravel-morphable)[ RSS](/packages/michielkempen-laravel-morphable/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Laravel Morphable
=================

[](#laravel-morphable)

A trait to morph Eloquent models to a child class based on a type field.

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

[](#installation)

Add the package to the dependencies of your application

```
composer require michielkempen/laravel-morphable

```

Usage
-----

[](#usage)

Add the `Morphable` trait to your model, and add a `factory` and `typeField` property. The `typeField` property is optional and defaults to `type`. The `factory` property is mandatory and needs to contain the path to a class which inherits the `MorphableModelFactory` interface.

```
