The short name defined in the morphMap is stored in the database
The class name of the model is stored in the database.
<?php
use Backend;
use October\Rain\Database\Relations\Relation;
use System\Classes\PluginBase;
/**
* Participation Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* Boot method, called right before the request route.
*
* @return array
*/
public function boot()
{
Relation::morphMap([
'model' => Author\Plugin\Models\Model::class,
]);
}
}
420
@CSNWEB @LukeTowers I have been using MorphMap just fine, the only difference is I pass a string of the class, like below:
Relation::morphMap([
'model' => 'Author\Plugin\Models\Model',
]);
Not sure if that would make a difference?
@mbaxter91288 Hm is hat should resolve to a string, but I will try. Did, you also did it in the boot method just like I am? Which use statement are you using? Thanks for your answer!
@CSNWEB yep in the boot method and use October\Rain\Database\Relations\Relation;
@CSNWEB you might have to prepend it with a backslash if you want to use the ::class method without importing the class in question with a use statement.
@LukeTowers Wow yes that was it, thought it would throw an error if it cannot find it, weird. Thanks a lot! And just fyi it even works with the old release and
use Illuminate\Database\Eloquent\Relations\Relation;