Skip to content

Commit af80685

Browse files
committed
fix model binding when cached
1 parent 9c1c839 commit af80685

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Illuminate/Routing/AbstractRouteCollection.php

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public function compile()
146146
'fallback' => $route->isFallback,
147147
'defaults' => $route->defaults,
148148
'wheres' => $route->wheres,
149+
'bindingFields' => $route->bindingFields(),
149150
];
150151
}
151152

src/Illuminate/Routing/CompiledRouteCollection.php

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function add(Route $route)
7070
'fallback' => $route->isFallback,
7171
'defaults' => $route->defaults,
7272
'wheres' => $route->wheres,
73+
'bindingFields' => $route->bindingFields(),
7374
];
7475

7576
$this->compiled = [];
@@ -244,6 +245,7 @@ protected function newRoute(array $attributes)
244245
->setFallback($attributes['fallback'])
245246
->setDefaults($attributes['defaults'])
246247
->setWheres($attributes['wheres'])
248+
->setBindingFields($attributes['bindingFields'])
247249
->setRouter($this->router)
248250
->setContainer($this->container);
249251
}

src/Illuminate/Routing/Route.php

+23
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,29 @@ public function bindingFieldFor($parameter)
488488
return $this->bindingFields[$parameter] ?? null;
489489
}
490490

491+
/**
492+
* Get the binding fields for the route.
493+
*
494+
* @return array
495+
*/
496+
public function bindingFields()
497+
{
498+
return $this->bindingFields ?? [];
499+
}
500+
501+
/**
502+
* Set the binding fields for the route.
503+
*
504+
* @param array $bindingFields
505+
* @return $this
506+
*/
507+
public function setBindingFields(array $bindingFields)
508+
{
509+
$this->bindingFields = $bindingFields;
510+
511+
return $this;
512+
}
513+
491514
/**
492515
* Get the parent parameter of the given parameter.
493516
*

0 commit comments

Comments
 (0)