I can find a number of discussions regarding this but no clear solution. Here are two links, although I will cover everything in my own question here.
Github Issues<
Let laravel put it into the db - namespace and all. If you need the short classname for something besides making your database prettier then define an accessor for something like :
morphOne('App\Photos\Photo', 'imageable');
}
public function getMorphObjectAttribute()
{
return (new \ReflectionClass($this))->getShortName();
}
}
The reasoning I always come back to in scenarios like this is that Laravel is pretty well tested, and works as expected for the most part. Why fight the framework if you don't have to - particularly if you are simply annoyed by the namespace being in the db. I agree it isn't a great idea to do so, but I also feel that I can spend my time more usefully getting over it and working on domain code.