Support the ongoing development of Laravel.io →
Database Eloquent Installation
Last updated 2 years ago.
0

Okay, I found a "solution":

--- ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php.bak  2017-06-07 09:22:30.072124838 +0200
+++ ./vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php      2017-06-07 09:24:24.353116784 +0200
@@ -116,7 +116,7 @@
         // link them up with their children using the keyed dictionary to make the
         // matching very convenient and easy work. Then we'll just return them.
         foreach ($models as $model) {
-            if (isset($dictionary[$key = $model->getAttribute($this->localKey)])) {
+            if (isset($dictionary[$key = strtoupper($model->getAttribute($this->localKey))])) {
                 $model->setRelation(
                     $relation, $this->getRelationValue($dictionary, $key, $type)
                 );
@@ -157,7 +157,7 @@
         // relationship as this will allow us to quickly access all of the related
         // models without having to do nested looping which will be quite slow.
         foreach ($results as $result) {
-            $dictionary[$result->{$foreign}][] = $result;
+            $dictionary[strtoupper($result->{$foreign})][] = $result;
         }

         return $dictionary;

With that solution, foreign key isn't longer case sensitive. Any pros and cons for that? Make that sense?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

prodigy7 prodigy7 Joined 7 Feb 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.