rinvex / laravel-bookings

⚠️ [ABANDONED] Rinvex Bookable is a generic resource booking system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
MIT License
459 stars 143 forks source link

Many To Many Relation #17

Closed angelformica closed 3 years ago

angelformica commented 6 years ago

Hello, first I want to thank you for sharing this great package.

I was wondering if it is possible to have multiple users attached to the same booking. In my use case, I use spatie/permissions to add role functionality to the users, so the same table can have customers, suppliers, and a few levels of admins. The thing is that I would like to, not only associate the booking with the user who is actually making the reservation, but also be able to attach the booking to supplier who is in charge of delivering that booked service.

I went through the code, and I noticed, that you have a polymorphic relation between the bookable resource and the user model that has the trait HasBookings. Would it make sense to change it to a ManyToMany Polymorphic?

Does this makes any sense?

I just forked the package to try make it work for me. If it does, would you care to include this feature in your code?

Best regards.

ShapesGraphicStudio commented 5 years ago

Hi, I'm interested by this post and enhacement, did you manage to get this working ? Some time to explain how ? Best regards, David

angelformica commented 5 years ago

Hi, I'm interested by this post and enhacement, did you manage to get this working ? Some time to explain how ? Best regards, David

Hello David, yes I got it working for my few months ago, here you can see the commit in my forked version, however I have not been following later changes from the base repository, also I did not really continue testing it, I've been busy with other things, but you can take a look at it, and let me know if it works for you:

https://github.com/angelformica/bookings/tree/ManyToMany

Best regards,

Omranic commented 3 years ago

I'm not sure why this is needed, because you can get all booking users through the bookable entity, which removes the need for having the same relationship (i.e. booking) attached to both the user & supplier.

Example:

Checkout https://github.com/rinvex/laravel-bookings/blob/b94ff8628f957336ec798ea566739ceee52fa96c/src/Traits/Bookable.php#L125-L145