Sunday, May 21, 2017

Specifying morphTo method target id column

Is there a way to specify target id column on morphTo method?

I'll give an example which is in documentation for laravel:

Post - Id, text

Video - Id, url

Comment - Id, text, commentable_id, commentable_type

But what if Ids on post and video were renamed to custom_id? How would I set up my eloquent model then? Thanks.



via M. Novotny

Advertisement