Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craftable Pro - Use Polymorphic relationships 1:1, 1:N, N:N with Craftable Pro possible with CRUD generator? #64

Open
rapgithub opened this issue Nov 28, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@rapgithub
Copy link

is it possible to use Polymorphic relationships with Craftable Pro, to have cleaner and simpler merging of relations and using the CRUD generator?

Example:

Schema:

$table->morphs(‘commentable’);

In the model Post Model

‘‘‘
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
‘‘‘

In the model Page Model

‘‘‘
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
‘‘‘

In the comment Page Model

‘‘‘
public function commentable()
{
return $this->morphTo();
}
‘‘‘

A sample of this is found here:

https://blog.logrocket.com/polymorphic-relationships-laravel/

The reason of this it is because I will like to add a Polymorphic relationships to the user model and allow users access their profile table according the user type selected when registering! Example of this will be a user type model and a user type agency both has a profile page with different columns to input in their profiles, etc...

Thanks for any tips!

@palypster
Copy link
Contributor

Thank you for the idea, we will consider adding this into our plan.

cc @strstensky @timoransky

@rapgithub
Copy link
Author

thanks!

@strstensky strstensky added the enhancement New feature or request label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants