jonspalmer / single-table-inheritance

A Single Table Inheritance Trait for Eloquent/Laravel
MIT License
249 stars 50 forks source link

Cannot construct newFromBuilder for unrecognized type= #40

Closed bsgrd closed 7 years ago

bsgrd commented 7 years ago

Hi, I'm trying to create a structure for different types of users but can't seem to get it to work, i get this error: Cannot construct newFromBuilder for unrecognized type=agency

class User extends Authenticatable
{
    use SingleTableInheritanceTrait;
    protected $table = 'users';
    protected static $singleTableTypeField = 'type';
    protected static $singleTableTypeClasses = [
        Agency::class
    ];    
}

class Agency extends User
{
    protected static $singleTableType = 'agency';
}

User i'm trying to get with User::find($user_id) has the "type" attribute set to "agency". I'm using Laravel 5.4

Am I missing something?

bsgrd commented 7 years ago

Had $singleTableTypeClasses in stead of $singleTableSubClasses. Everything is working now.