https://github.com/dillingham/morphable
resolve morph models in controllers by type & id
https://github.com/dillingham/morphable
laravel
Last synced: about 2 months ago
JSON representation
resolve morph models in controllers by type & id
- Host: GitHub
- URL: https://github.com/dillingham/morphable
- Owner: dillingham
- License: mit
- Created: 2019-08-23T16:49:34.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-24T00:53:37.000Z (almost 7 years ago)
- Last Synced: 2025-02-07T00:28:48.905Z (over 1 year ago)
- Topics: laravel
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Morphable
[](https://packagist.org/packages/dillingham/morphable)
[](https://packagist.org/packages/dillingham/morphable) [](https://twitter.com/dillinghammm)
```
composer require dillingham/morphable
```
- Add `Morphable` to a model
- Add `ResolveMorphs` to your base controller
- Fill `$morphable` on a controller with model classes
- Submit `type` and `id` to a controller
- adds `->forMorph($model)` to fill object_type, object_id
```php
resolveMorph();
$comment = new Comment;
$comment->forMorph($model);
$comment->save();
}
}
```