2
I have two functions in the controller and need to pass the return of a function to the other and save in a variable, but is giving error.
function that returns
public function getarrcontatos(Request $request){
$value = $request->get('value');
$ArrContatos = [];
$ArrContatos = $value;
return ($ArrContatos);
}
Function it receives
public function store(Request $request){
$input = $request->all();
$obscontatos = $request->input('obscontatos');
$result = count($obscontatos);
for ($i = 0; $i < $result ; $i++) {
$listacontatos = getarrcontatos();
$contatoarray = array('idContato'=>$listacontatos[1],'ccContato'=>$listacontatos[2], 'idObsContato'=>$listacontatos[0]);
DB::table('contatoObsCc')->insert($contatoarray);
}
}
These two functions are in the Laravel controller.
The code line of errp is: $listacontatos = getarrcontatos();
Are in the same controller?
– JrD
Yes, they’re in the same controller
– Lorena