Commit ff5b6315 authored by Taylor Otwell's avatar Taylor Otwell

added array access to session::Get

parent a6c0407e
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
## Version 2.0.5 ## Version 2.0.5
- Feature: Added array access to session::get.
- Fix: Remove orderings before running pagination queries. - Fix: Remove orderings before running pagination queries.
- Fix: Session flush now correctly prepares empty data. - Fix: Session flush now correctly prepares empty data.
- Fix: DB::raw now works on Eloquent properties. - Fix: DB::raw now works on Eloquent properties.
......
...@@ -142,17 +142,23 @@ class Payload { ...@@ -142,17 +142,23 @@ class Payload {
*/ */
public function get($key, $default = null) public function get($key, $default = null)
{ {
if (isset($this->session['data'][$key])) $session = $this->session['data'];
// We check for the item in the general session data first, and if it
// does not exist in that data, we will attempt to find it in the new
// and old flash data. If none of those arrays contain the requested
// item, we will just return the default value.
if ( ! is_null($value = Arr::get($session, $key)))
{ {
return $this->session['data'][$key]; return $value;
} }
elseif (isset($this->session['data'][':new:'][$key])) elseif ( ! is_null($value = Arr::get($session[':new:'], $key)))
{ {
return $this->session['data'][':new:'][$key]; return $value;
} }
elseif (isset($this->session['data'][':old:'][$key])) elseif ( ! is_null($value = Arr::get($session[':old:'], $key)))
{ {
return $this->session['data'][':old:'][$key]; return $value;
} }
return ($default instanceof Closure) ? call_user_func($default) : $default; return ($default instanceof Closure) ? call_user_func($default) : $default;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment