@@ -69,7 +69,7 @@ public function __construct(
6969     */ 
7070    public  function  hint ()
7171    {
72-         return  '\\' . Collection::class. '| ' . $ this reference ->getQualifiedUserClassName (). '[] ' ;
72+         return  '\\'  .  Collection::class .  '| '  .  $ this reference ->getQualifiedUserClassName () .  '[] ' ;
7373    }
7474
7575    /** 
@@ -99,32 +99,32 @@ public function body()
9999    {
100100        $ body'return $this->belongsToMany( ' ;
101101
102-         $ body$ this reference ->getQualifiedUserClassName (). '::class ' ;
102+         $ body$ this reference ->getQualifiedUserClassName () .  '::class ' ;
103103
104104        if  ($ this needsPivotTable ()) {
105-             $ body',  ' . Dumper::export ($ this pivotTable ());
105+             $ body',  '  .  Dumper::export ($ this pivotTable ());
106106        }
107107
108108        if  ($ this needsForeignKey ()) {
109109            $ foreignKey$ this parent ->usesPropertyConstants ()
110-                 ? $ this reference ->getQualifiedUserClassName (). ':: ' . strtoupper ($ this foreignKey ())
110+                 ? $ this reference ->getQualifiedUserClassName () .  ':: '  .  strtoupper ($ this foreignKey ())
111111                : $ this foreignKey ();
112-             $ body',  ' . Dumper::export ($ foreignKey
112+             $ body',  '  .  Dumper::export ($ foreignKey
113113        }
114114
115115        if  ($ this needsOtherKey ()) {
116116            $ otherKey$ this reference ->usesPropertyConstants ()
117-                 ? $ this reference ->getQualifiedUserClassName (). ':: ' . strtoupper ($ this otherKey ())
117+                 ? $ this reference ->getQualifiedUserClassName () .  ':: '  .  strtoupper ($ this otherKey ())
118118                : $ this otherKey ();
119-             $ body',  ' . Dumper::export ($ otherKey
119+             $ body',  '  .  Dumper::export ($ otherKey
120120        }
121121
122122        $ body') ' ;
123123
124124        $ fields$ this getPivotFields ();
125125
126-         if  (!  empty ($ fields
127-             $ body"\n\t\t\t\t\t->withPivot( " . $ this parametrize ($ fields. ') ' ;
126+         if  (!empty ($ fields
127+             $ body"\n\t\t\t\t\t->withPivot( "  .  $ this parametrize ($ fields .  ') ' ;
128128        }
129129
130130        if  ($ this pivot ->usesTimestamps ()) {
@@ -173,7 +173,11 @@ protected function pivotTable()
173173     */ 
174174    protected  function  needsForeignKey ()
175175    {
176-         $ defaultForeignKey$ this parentRecordName ().'_id ' ;
176+         if  ($ this parent ->config ('relation.options.show_key ' )) {
177+             return  true ;
178+         }
179+ 
180+         $ defaultForeignKey$ this parentRecordName () . '_id ' ;
177181
178182        return  $ this foreignKey () != $ defaultForeignKey$ this needsOtherKey ();
179183    }
@@ -191,7 +195,12 @@ protected function foreignKey()
191195     */ 
192196    protected  function  needsOtherKey ()
193197    {
194-         $ defaultOtherKey$ this referenceRecordName ().'_id ' ;
198+ 
199+         if  ($ this parent ->config ('relation.options.show_key ' )) {
200+             return  true ;
201+         }
202+ 
203+         $ defaultOtherKey$ this referenceRecordName () . '_id ' ;
195204
196205        return  $ this otherKey () != $ defaultOtherKey
197206    }
@@ -241,10 +250,10 @@ private function parametrize($fields = [])
241250    {
242251        return  (string ) implode (',  ' , array_map (function  ($ field
243252            $ field$ this reference ->usesPropertyConstants ()
244-                 ? $ this pivot ->getQualifiedUserClassName (). ':: ' . strtoupper ($ field
253+                 ? $ this pivot ->getQualifiedUserClassName () .  ':: '  .  strtoupper ($ field
245254                : $ field
246255
247256            return  Dumper::export ($ field
248257        }, $ fields
249258    }
250- }
259+ }
0 commit comments