when i want to save changes in laravel , see this error :
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Http\Response
*/
public function arrangeRoleItem($content, $module_name)
{
if (array_key_exists(1, $content )) { //Module Show
$module_show = 1;
} else {
$module_show = 0;
}
if (array_key_exists(2, $content)) { // Show
$show = 1;
} else {
$show = 0;
}
if (array_key_exists(3, $content)) { // Create
$create = 1;
} else {
$create = 0;
}
if (array_key_exists(4, $content)) { // Edit
$edit = 1;
} else {
$edit = 0;
Arguments "array_key_exists() expects parameter 2 to be array, null given"
thanks for responses .
CodePudding user response:
Your $content
variable is null
value but array_key_exists
function expects second parameter is array
You need to set default value like this:
/**
* Arrange role item
*
* @param array $content
* @param string $module_name
* @return boolean $bool
*/
public function arrangeRoleItem($content = [], $module_name)
CodePudding user response:
@フクちゃん thans . error resolved but (!) Changes are not applied to the database