Using Other Column As Identifier In Polymorphic Relationship
I am using Eloquent on my project and I am currently facing a problem with regards to polymorphic relations. What I would like to do is to specify another column instead of the primary key in morphing relationship such that:
In this scenario, I would like to create a relation with both the products and the users table, but in the product relationship, instead of putting the ID as the relationship identifier, I would like to put the
product_number because of some reasons. Is it possible as of version 5.1?
It is possible by specifying the local key like so:
return $this->morphMany('App\Photos', 'imageable', null, null, 'product_number' );
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?