Look at this package.
Pivot table between 3 tables
Hello,
So lets say i have an organisation(company) which has many sites(location) and many contacts(user) but contacts shares both table, organisations and sites table. is this possible to achieve something like : $organisations->sites()->contacts in Laravel ?
thanks, exactly what i need but i m on Laravel 5 and its seems that composer doesnt like it lol. Your requirements could not be resolved to an installable set of packages.
Problem 1 - Conclusion: remove laravel/framework v5.0.27 - Conclusion: don't install laravel/framework v5.0.27 - Conclusion: don't install laravel/framework v5.0.26 - Conclusion: don't install laravel/framework v5.0.25 - Conclusion: don't install laravel/framework v5.0.24 - Conclusion: don't install laravel/framework v5.0.23 - Conclusion: don't install laravel/framework v5.0.22 - Conclusion: don't install laravel/framework v5.0.21 - Conclusion: don't install laravel/framework v5.0.20 - Conclusion: don't install laravel/framework v5.0.19 - Conclusion: don't install laravel/framework v5.0.18 - Conclusion: don't install laravel/framework v5.0.17 - Conclusion: don't install laravel/framework v5.0.16 - Conclusion: don't install laravel/framework v5.0.15 - Conclusion: don't install laravel/framework v5.0.14 - Conclusion: don't install laravel/framework v5.0.13 - Conclusion: don't install laravel/framework v5.0.12 - Conclusion: don't install laravel/framework v5.0.11 - Conclusion: don't install laravel/framework v5.0.10 - Conclusion: don't install laravel/framework v5.0.9 - Conclusion: don't install laravel/framework v5.0.8 - Conclusion: don't install laravel/framework v5.0.7 - Conclusion: don't install laravel/framework v5.0.6 - Conclusion: don't install laravel/framework v5.0.5 - Conclusion: don't install laravel/framework v5.0.4 - Conclusion: don't install laravel/framework v5.0.3 - Installation request for jarektkaczyk/eloquent-triple-pivot dev-master -> satisfiable by jarektkaczyk/eloquent-triple-pivot[dev-master]. - Conclusion: don't install laravel/framework v5.0.2 - Conclusion: don't install laravel/framework v5.0.1 - jarektkaczyk/eloquent-triple-pivot dev-master requires illuminate/support 4.2.* -> satisfiable by illuminate/support[v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9]. - don't install illuminate/support v4.2.1|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.12|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.16|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.17|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.2|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.3|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.4|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.5|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.6|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.7|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.8|don't install laravel/framework v5.0.0 - don't install illuminate/support v4.2.9|don't install laravel/framework v5.0.0 - Installation request for laravel/framework 5.0.* -> satisfiable by laravel/framework[v5.0.0, v5.0.1, v5.0.10, v5.0.11, v5.0.12, v5.0.13, v5.0.14, v5.0.15, v5.0.16, v5.0.17, v5.0.18, v5.0.19, v5.0.2, v5.0.20, v5.0.21, v5.0.22, v5.0.23, v5.0.24, v5.0.25, v5.0.26, v5.0.27, v5.0.3, v5.0.4, v5.0.5, v5.0.6, v5.0.7, v5.0.8, v5.0.9].
Fork the package and update framework reference in composer.json :
"require": {
"php": ">=5.4.0",
"illuminate/support": "5.0.*"
},
And in your application :
"repositories": [
{
"type": "vcs",
"url": "https://github.com/your_name_here/eloquent-triple-pivot.git"
}
],
"require": {
"laravel/framework": "5.0.*",
"jarektkaczyk/eloquent-triple-pivot": "dev-master"
},
So it will be installed and you'll see if it works for L5 ;)
Triple pivot table is hell. Try to introduce another model (which may not have a concrete real life representation but don't care) to get back to classic two sided relationships. Here this model would represent a couple of organisation/site which belongs to many users.
why do you think its hell ? Imo, in my case it would be nice. @bestmomo Thanks!
I don't say it is bad I meant eloquent is not made to handle this, it will be a lot of headaches. Try to introduce another model as I explained above it is much more suited to eloquent.
I've been having the same problem @lameduze , I have three tables: jobs, filters, and options. An option belongs to a filter, and a job can have many filter / options. I have a filter_job_option table to build relationships but I'm trying to figure out a good way to manage these relationships without having a huge cluster of messy queries / blade template files. I feel like this kind of relationship is rather common and something that Eloquent should be able to handle, it's unfortunate that it can't.
Please or to participate in this conversation.