eeight
1 week ago

One To One (Polymorphic) - nullable?

Posted 1 week ago by eeight

Is it possible to have a One To One Polymorphic relationship nullable? I want to extend the users table (adding userable_type and userable_id) and 2 morping tables (mentors & artists), but now when trying to create an user I have a message that userable_id cannot be null.

Would it work to simply turns that field nullable but keep the model relation (morphTo() & morphOne('App\User', 'userable')?

Please sign in or create an account to participate in this conversation.