I have custom helper, class, in my Laravel project:
<?php
namespace App\Http\Helpers;
class FoxUtils {
public static function isAuthTo($name)
{
if (self::test($name)){
\Session::push('AuthList',[$name => true]);
return true;
}
else{
\Session::push('AuthList',[$name => false]);
return false;
}
}
}
There two notes:
The session variable AuthList is numerical indexed array with values as arrays like the following:
array:2 [▼
0 => array:1 [▼
"name1" => true
]
1 => array:1 [▼
"newName" => true
]
]
The value "name1" => true is defined from other place than my helper. When I try to use my helper's method I respect new keys should be added to the array:
\FoxUtils::isAuthTo('AnotherName');
dd(session('AuthList'))
the above code prints array with only two keys while I expect three:
array:2 [▼
0 => array:1 [▼
"name1" => true
]
1 => array:1 [▼
"AnotherName" => true
]
]
In other words, always the last value of the AuthList is replaced with new value! What is the problem here?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire