From df38a92bd936ac12ed47ba91e4ff2aa27fd4056a Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Thu, 7 Apr 2016 13:07:16 +0530 Subject: [PATCH] Fix bug in has query contruct Fixes #13 --- composer.json | 5 +- composer.lock | 280 +++++++++++++++++------------ src/Relations/BelongsToThrough.php | 65 ++++--- 3 files changed, 204 insertions(+), 146 deletions(-) diff --git a/composer.json b/composer.json index fc54f8c..9f52dea 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "model" ], "require": { - "illuminate/database": ">4.0" + "illuminate/database": "~5.0" }, "require-dev": { "phpunit/phpunit": "~5.0", @@ -33,7 +33,8 @@ } }, "scripts": { - "test": "phpunit" + "test": "phpunit", + "cs": "php-cs-fixer fix" }, "minimum-stability": "stable" } diff --git a/composer.lock b/composer.lock index b810965..8b25088 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "77f88513e3b8d5017cd370dcd8061fde", - "content-hash": "1e7ab5a23ed093348ddd350832254d24", + "hash": "50e9061430ab4a254b74da7735e14a40", + "content-hash": "462a605a7caef4fd0d28e7e2a465ffb7", "packages": [ { "name": "classpreloader/classpreloader", @@ -308,16 +308,16 @@ }, { "name": "laravel/framework", - "version": "v5.2.23", + "version": "v5.2.29", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "87c090845f135ca94eba903f1c8462e60e3a6e36" + "reference": "e3d644eb131f18c5f3d28ff7bc678bc797091f20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/87c090845f135ca94eba903f1c8462e60e3a6e36", - "reference": "87c090845f135ca94eba903f1c8462e60e3a6e36", + "url": "https://api.github.com/repos/laravel/framework/zipball/e3d644eb131f18c5f3d28ff7bc678bc797091f20", + "reference": "e3d644eb131f18c5f3d28ff7bc678bc797091f20", "shasum": "" }, "require": { @@ -330,7 +330,7 @@ "monolog/monolog": "~1.11", "mtdowling/cron-expression": "~1.0", "nesbot/carbon": "~1.20", - "paragonie/random_compat": "~1.1", + "paragonie/random_compat": "~1.4", "php": ">=5.5.9", "psy/psysh": "0.7.*", "swiftmailer/swiftmailer": "~5.1", @@ -432,7 +432,7 @@ "framework", "laravel" ], - "time": "2016-03-14 14:22:33" + "time": "2016-04-03 01:43:55" }, { "name": "league/flysystem", @@ -519,16 +519,16 @@ }, { "name": "monolog/monolog", - "version": "1.18.1", + "version": "1.18.2", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "a5f2734e8c16f3aa21b3da09715d10e15b4d2d45" + "reference": "064b38c16790249488e7a8b987acf1c9d7383c09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/a5f2734e8c16f3aa21b3da09715d10e15b4d2d45", - "reference": "a5f2734e8c16f3aa21b3da09715d10e15b4d2d45", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/064b38c16790249488e7a8b987acf1c9d7383c09", + "reference": "064b38c16790249488e7a8b987acf1c9d7383c09", "shasum": "" }, "require": { @@ -543,13 +543,13 @@ "doctrine/couchdb": "~1.0@dev", "graylog2/gelf-php": "~1.0", "jakub-onderka/php-parallel-lint": "0.9", + "php-amqplib/php-amqplib": "~2.4", "php-console/php-console": "^3.1.3", "phpunit/phpunit": "~4.5", "phpunit/phpunit-mock-objects": "2.3.0", "raven/raven": "^0.13", "ruflin/elastica": ">=0.90 <3.0", - "swiftmailer/swiftmailer": "~5.3", - "videlalvaro/php-amqplib": "~2.4" + "swiftmailer/swiftmailer": "~5.3" }, "suggest": { "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", @@ -558,11 +558,11 @@ "ext-mongo": "Allow sending log messages to a MongoDB server", "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", "php-console/php-console": "Allow sending log messages to Google Chrome", "raven/raven": "Allow sending log messages to a Sentry server", "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server", - "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib" + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" }, "type": "library", "extra": { @@ -593,7 +593,7 @@ "logging", "psr-3" ], - "time": "2016-03-13 16:08:35" + "time": "2016-04-02 13:12:58" }, { "name": "mtdowling/cron-expression", @@ -739,16 +739,16 @@ }, { "name": "paragonie/random_compat", - "version": "v1.3.0", + "version": "v1.4.1", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "ff76e1a660669bb56ba74ba0583fd8d41417bf39" + "reference": "c7e26a21ba357863de030f0b9e701c7d04593774" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/ff76e1a660669bb56ba74ba0583fd8d41417bf39", - "reference": "ff76e1a660669bb56ba74ba0583fd8d41417bf39", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/c7e26a21ba357863de030f0b9e701c7d04593774", + "reference": "c7e26a21ba357863de030f0b9e701c7d04593774", "shasum": "" }, "require": { @@ -783,7 +783,7 @@ "pseudorandom", "random" ], - "time": "2016-03-17 16:11:57" + "time": "2016-03-18 20:34:03" }, { "name": "psr/log", @@ -950,16 +950,16 @@ }, { "name": "symfony/console", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "2ed5e2706ce92313d120b8fe50d1063bcfd12e04" + "reference": "6b1175135bc2a74c08a28d89761272de8beed8cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/2ed5e2706ce92313d120b8fe50d1063bcfd12e04", - "reference": "2ed5e2706ce92313d120b8fe50d1063bcfd12e04", + "url": "https://api.github.com/repos/symfony/console/zipball/6b1175135bc2a74c08a28d89761272de8beed8cd", + "reference": "6b1175135bc2a74c08a28d89761272de8beed8cd", "shasum": "" }, "require": { @@ -1006,20 +1006,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-02-28 16:24:34" + "time": "2016-03-16 17:00:50" }, { "name": "symfony/debug", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "29606049ced1ec715475f88d1bbe587252a3476e" + "reference": "a06d10888a45afd97534506afb058ec38d9ba35b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/29606049ced1ec715475f88d1bbe587252a3476e", - "reference": "29606049ced1ec715475f88d1bbe587252a3476e", + "url": "https://api.github.com/repos/symfony/debug/zipball/a06d10888a45afd97534506afb058ec38d9ba35b", + "reference": "a06d10888a45afd97534506afb058ec38d9ba35b", "shasum": "" }, "require": { @@ -1063,20 +1063,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-03-30 10:41:14" }, { "name": "symfony/event-dispatcher", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa" + "reference": "9002dcf018d884d294b1ef20a6f968efc1128f39" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", - "reference": "4dd5df31a28c0f82b41cb1e1599b74b5dcdbdafa", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9002dcf018d884d294b1ef20a6f968efc1128f39", + "reference": "9002dcf018d884d294b1ef20a6f968efc1128f39", "shasum": "" }, "require": { @@ -1123,20 +1123,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-03-10 10:34:12" }, { "name": "symfony/finder", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723" + "reference": "c54e407b35bc098916704e9fd090da21da4c4f52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723", - "reference": "623bda0abd9aa29e529c8e9c08b3b84171914723", + "url": "https://api.github.com/repos/symfony/finder/zipball/c54e407b35bc098916704e9fd090da21da4c4f52", + "reference": "c54e407b35bc098916704e9fd090da21da4c4f52", "shasum": "" }, "require": { @@ -1172,24 +1172,25 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-03-10 11:13:05" }, { "name": "symfony/http-foundation", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "52065702c71743c05d415a8facfcad6d4257e8d7" + "reference": "99f38445a874e7becb8afc4b4a79ee181cf6ec3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/52065702c71743c05d415a8facfcad6d4257e8d7", - "reference": "52065702c71743c05d415a8facfcad6d4257e8d7", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/99f38445a874e7becb8afc4b4a79ee181cf6ec3f", + "reference": "99f38445a874e7becb8afc4b4a79ee181cf6ec3f", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.1" }, "require-dev": { "symfony/expression-language": "~2.8|~3.0" @@ -1224,20 +1225,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2016-02-28 16:24:34" + "time": "2016-03-27 14:50:32" }, { "name": "symfony/http-kernel", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "59c0a1972e9aad87b7a56bbe1ccee26b7535a0db" + "reference": "579f828489659d7b3430f4bd9b67b4618b387dea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/59c0a1972e9aad87b7a56bbe1ccee26b7535a0db", - "reference": "59c0a1972e9aad87b7a56bbe1ccee26b7535a0db", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/579f828489659d7b3430f4bd9b67b4618b387dea", + "reference": "579f828489659d7b3430f4bd9b67b4618b387dea", "shasum": "" }, "require": { @@ -1306,7 +1307,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2016-02-28 21:33:13" + "time": "2016-03-25 01:41:20" }, { "name": "symfony/polyfill-mbstring", @@ -1477,16 +1478,16 @@ }, { "name": "symfony/process", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "dfecef47506179db2501430e732adbf3793099c8" + "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/dfecef47506179db2501430e732adbf3793099c8", - "reference": "dfecef47506179db2501430e732adbf3793099c8", + "url": "https://api.github.com/repos/symfony/process/zipball/e6f1f98bbd355d209a992bfff45e7edfbd4a0776", + "reference": "e6f1f98bbd355d209a992bfff45e7edfbd4a0776", "shasum": "" }, "require": { @@ -1522,20 +1523,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-02-02 13:44:19" + "time": "2016-03-30 10:41:14" }, { "name": "symfony/routing", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "fa1e9a8173cf0077dd995205da453eacd758fdf6" + "reference": "d061b609f2d0769494c381ec92f5c5cc5e4a20aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/fa1e9a8173cf0077dd995205da453eacd758fdf6", - "reference": "fa1e9a8173cf0077dd995205da453eacd758fdf6", + "url": "https://api.github.com/repos/symfony/routing/zipball/d061b609f2d0769494c381ec92f5c5cc5e4a20aa", + "reference": "d061b609f2d0769494c381ec92f5c5cc5e4a20aa", "shasum": "" }, "require": { @@ -1597,20 +1598,20 @@ "uri", "url" ], - "time": "2016-02-04 13:53:13" + "time": "2016-03-23 13:23:25" }, { "name": "symfony/translation", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "2de0b6f7ebe43cffd8a06996ebec6aab79ea9e91" + "reference": "f7a07af51ea067745a521dab1e3152044a2fb1f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/2de0b6f7ebe43cffd8a06996ebec6aab79ea9e91", - "reference": "2de0b6f7ebe43cffd8a06996ebec6aab79ea9e91", + "url": "https://api.github.com/repos/symfony/translation/zipball/f7a07af51ea067745a521dab1e3152044a2fb1f2", + "reference": "f7a07af51ea067745a521dab1e3152044a2fb1f2", "shasum": "" }, "require": { @@ -1661,20 +1662,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2016-02-02 13:44:19" + "time": "2016-03-25 01:41:20" }, { "name": "symfony/var-dumper", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "9a6a883c48acb215d4825ce9de61dccf93d62074" + "reference": "3841ed86527d18ee2c35fe4afb1b2fc60f8fae79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/9a6a883c48acb215d4825ce9de61dccf93d62074", - "reference": "9a6a883c48acb215d4825ce9de61dccf93d62074", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/3841ed86527d18ee2c35fe4afb1b2fc60f8fae79", + "reference": "3841ed86527d18ee2c35fe4afb1b2fc60f8fae79", "shasum": "" }, "require": { @@ -1724,7 +1725,7 @@ "debug", "dump" ], - "time": "2016-02-13 09:23:44" + "time": "2016-03-10 10:34:12" }, { "name": "vlucas/phpdotenv", @@ -2544,16 +2545,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.2.12", + "version": "5.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6f0948bab32270352f97d1913d82a49338dcb0da" + "reference": "dd3001822b2df8f5add266020e3d2fd3c5db3ae9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6f0948bab32270352f97d1913d82a49338dcb0da", - "reference": "6f0948bab32270352f97d1913d82a49338dcb0da", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/dd3001822b2df8f5add266020e3d2fd3c5db3ae9", + "reference": "dd3001822b2df8f5add266020e3d2fd3c5db3ae9", "shasum": "" }, "require": { @@ -2569,12 +2570,13 @@ "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": ">=1.0.6", - "phpunit/phpunit-mock-objects": ">=3.0.5", + "phpunit/phpunit-mock-objects": "^3.1", "sebastian/comparator": "~1.1", "sebastian/diff": "~1.2", "sebastian/environment": "~1.3", "sebastian/exporter": "~1.2", "sebastian/global-state": "~1.0", + "sebastian/object-enumerator": "~1.0", "sebastian/resource-operations": "~1.0", "sebastian/version": "~1.0|~2.0", "symfony/yaml": "~2.1|~3.0" @@ -2588,7 +2590,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.2.x-dev" + "dev-master": "5.3.x-dev" } }, "autoload": { @@ -2614,20 +2616,20 @@ "testing", "xunit" ], - "time": "2016-03-15 05:59:58" + "time": "2016-03-31 21:35:50" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.0.6", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "49bc700750196c04dd6bc2c4c99cb632b893836b" + "reference": "7c34c9bdde4131b824086457a3145e27dba10ca1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/49bc700750196c04dd6bc2c4c99cb632b893836b", - "reference": "49bc700750196c04dd6bc2c4c99cb632b893836b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/7c34c9bdde4131b824086457a3145e27dba10ca1", + "reference": "7c34c9bdde4131b824086457a3145e27dba10ca1", "shasum": "" }, "require": { @@ -2645,7 +2647,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -2670,7 +2672,7 @@ "mock", "xunit" ], - "time": "2015-12-08 08:47:06" + "time": "2016-03-24 05:58:25" }, { "name": "satooshi/php-coveralls", @@ -3058,6 +3060,52 @@ ], "time": "2015-10-12 03:26:01" }, + { + "name": "sebastian/object-enumerator", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "d4ca2fb70344987502567bc50081c03e6192fb26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d4ca2fb70344987502567bc50081c03e6192fb26", + "reference": "d4ca2fb70344987502567bc50081c03e6192fb26", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2016-01-28 13:25:10" + }, { "name": "sebastian/recursion-context", "version": "1.0.2", @@ -3198,16 +3246,16 @@ }, { "name": "symfony/config", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "79a97025f7bf4bbf8352b5df1905aa136a531066" + "reference": "980ee40c28f00acff8906c11b778aab5f0db74c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/79a97025f7bf4bbf8352b5df1905aa136a531066", - "reference": "79a97025f7bf4bbf8352b5df1905aa136a531066", + "url": "https://api.github.com/repos/symfony/config/zipball/980ee40c28f00acff8906c11b778aab5f0db74c2", + "reference": "980ee40c28f00acff8906c11b778aab5f0db74c2", "shasum": "" }, "require": { @@ -3247,20 +3295,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-02-23 15:16:06" + "time": "2016-03-04 07:55:57" }, { "name": "symfony/css-selector", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "6605602690578496091ac20ec7a5cbd160d4dff4" + "reference": "65e764f404685f2dc20c057e889b3ad04b2e2db0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/6605602690578496091ac20ec7a5cbd160d4dff4", - "reference": "6605602690578496091ac20ec7a5cbd160d4dff4", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/65e764f404685f2dc20c057e889b3ad04b2e2db0", + "reference": "65e764f404685f2dc20c057e889b3ad04b2e2db0", "shasum": "" }, "require": { @@ -3300,20 +3348,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2016-01-27 05:14:46" + "time": "2016-03-04 07:55:57" }, { "name": "symfony/dom-crawler", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "981c8edb4538f88ba976ed44bdcaa683fce3d6c6" + "reference": "18a06d7a9af41718c20764a674a0ebba3bc40d1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/981c8edb4538f88ba976ed44bdcaa683fce3d6c6", - "reference": "981c8edb4538f88ba976ed44bdcaa683fce3d6c6", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/18a06d7a9af41718c20764a674a0ebba3bc40d1f", + "reference": "18a06d7a9af41718c20764a674a0ebba3bc40d1f", "shasum": "" }, "require": { @@ -3356,20 +3404,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2016-02-28 16:24:34" + "time": "2016-03-23 13:23:25" }, { "name": "symfony/filesystem", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451" + "reference": "f82499a459dcade2ea56df94cc58b19c8bde3d20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/23ae8f9648d0a7fe94a47c8e20e5bf37c489a451", - "reference": "23ae8f9648d0a7fe94a47c8e20e5bf37c489a451", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/f82499a459dcade2ea56df94cc58b19c8bde3d20", + "reference": "f82499a459dcade2ea56df94cc58b19c8bde3d20", "shasum": "" }, "require": { @@ -3405,20 +3453,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-02-23 15:16:06" + "time": "2016-03-27 10:24:39" }, { "name": "symfony/stopwatch", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "4a204804952ff267ace88cf499e0b4bb302a475e" + "reference": "6015187088421e9499d8f8316bdb396f8b806c06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/4a204804952ff267ace88cf499e0b4bb302a475e", - "reference": "4a204804952ff267ace88cf499e0b4bb302a475e", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6015187088421e9499d8f8316bdb396f8b806c06", + "reference": "6015187088421e9499d8f8316bdb396f8b806c06", "shasum": "" }, "require": { @@ -3454,20 +3502,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2016-01-03 15:35:16" + "time": "2016-03-04 07:55:57" }, { "name": "symfony/yaml", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c" + "reference": "0047c8366744a16de7516622c5b7355336afae96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/b5ba64cd67ecd6887f63868fa781ca094bd1377c", - "reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c", + "url": "https://api.github.com/repos/symfony/yaml/zipball/0047c8366744a16de7516622c5b7355336afae96", + "reference": "0047c8366744a16de7516622c5b7355336afae96", "shasum": "" }, "require": { @@ -3503,7 +3551,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-02-23 15:16:06" + "time": "2016-03-04 07:55:57" } ], "aliases": [], diff --git a/src/Relations/BelongsToThrough.php b/src/Relations/BelongsToThrough.php index f9a0886..f023df8 100644 --- a/src/Relations/BelongsToThrough.php +++ b/src/Relations/BelongsToThrough.php @@ -98,6 +98,24 @@ protected function setJoins() } } + /** + * Get foreign key column name for the model. + * + * @param \Illuminate\Database\Eloquent\Model $model + * + * @return string + */ + protected function getForeignKey(Model $model) + { + $table = $model->getTable(); + + if (array_key_exists($table, $this->foreignKeyLookup)) { + return $this->foreignKeyLookup[$table]; + } + + return Str::singular($table).'_id'; + } + /** * Get the underlying query for the relation. * @@ -120,24 +138,6 @@ protected function setSoftDeletes() } } - /** - * Get foreign key column name for the model. - * - * @param \Illuminate\Database\Eloquent\Model $model - * - * @return string - */ - protected function getForeignKey(Model $model) - { - $table = $model->getTable(); - - if (array_key_exists($table, $this->foreignKeyLookup)) { - return $this->foreignKeyLookup[$table]; - } - - return Str::singular($table).'_id'; - } - /** * Determine whether the model uses Soft Deletes. * @@ -165,24 +165,17 @@ public function addEagerConstraints(array $models) } /** - * Add the constraints for a relationship count query. - * - * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query - * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $parent - * - * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder + * @param Builder $query */ - public function getRelationCountQuery(Builder $query, Builder $parent) + protected function setRelationQueryConstraints(Builder $query) { - $query->select(new Expression('count(*)')); - $one = $this->getRelated()->getQualifiedKeyName(); $prev = $this->getForeignKey($this->getRelated()); $alias = null; $lastIndex = count($this->models); foreach ($this->models as $index => $model) { if ($lastIndex === $index) { - $prev = $this->prefix.$prev; + $prev = $this->prefix.$prev; // TODO: Check if this line is really necessary. Its not covered by any of the tests. } if ($this->getParent()->getTable() == $model->getTable()) { $alias = $model->getTable().'_'.time(); @@ -200,6 +193,22 @@ public function getRelationCountQuery(Builder $query, Builder $parent) $key = $this->wrap($this->getQualifiedParentKeyName()); $query->where(new Expression($alias.'.'.$this->getParent()->getKeyName()), '=', new Expression($key)); + } + + /** + * Add the constraints for a relationship query. + * + * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query + * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $parent + * @param array|mixed $columns + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationQuery(Builder $query, Builder $parent, $columns = ['*']) + { + $query->select($columns); + + $this->setRelationQueryConstraints($query); return $query; }