laravel-favorite icon indicating copy to clipboard operation
laravel-favorite copied to clipboard

[Request] Morphable favouriter?

Open natecorkish opened this issue 3 years ago • 4 comments

Currently we only allow a 'user' to favourite a model, would it be possible in the future to allow many models to favourite many models?

For example:

  • User::class can favourite Status::class
  • Page::class can favourite Image::class
  • Page::class can favourite Status::class

natecorkish avatar Jul 11 '22 19:07 natecorkish

Hello, thanks for the suggestion, but I still don't quite understand how non-human behavior can have the action " favorite ", it is not a technical problem, but the question of whether it is necessary or not, is there a more realistic scenario?

overtrue avatar Jul 12 '22 06:07 overtrue

Let's take facebook for example

Pages (https://www.facebook.com/facebookUK/?brand_redir=20531316728) can perform actions when logged in as a page...

natecorkish avatar Jul 13 '22 23:07 natecorkish

@natecorkish I think you can create a User variant to implement it. For example, add a field to mark this User as a Page using: type:page.

overtrue avatar Jul 16 '22 01:07 overtrue

Or add a parent_id to the User model:

user A has two pages:

users:

id nickname parent_id
1 A 0
2 Page1 1
3 Page2 1

pages:

ID user_id name
1 2 Page1
2 3 Page2

overtrue avatar Jul 16 '22 02:07 overtrue