I have a function in a class in App/src/utils. I have issue using it from a controller.
I have to construct some sheets with phpspreadsheet. The method length is 260 lines. I don't think it's a good practice to have it in a function of the controller. So, I try to put it in a class (ExcelCreate) I have created in App/Utils, in a public function called excelfrais, which create the sheet, using an array, called $data, and 2 variables called $user and $nblig. The function save the sheet, and send it to the browser. I put a "use App\Utils\ExcelCreate;" in my controller I call the function from the controller.
use App\Utils\ExcelCreate;
...
class ComiteController extends Controller
{
public function frais(Request $request, $nblig)
{ ...
$data=$form->getData();
$nblig=$data['nblig'];
excelfrais($user,$data,$nblig); ...
}}
And there is my issue : I have an Exception : Attempted to call function "excelfrais" from namespace "App\Controller"