Some functions in laravel are like you have to use in every controller , like saving an image ,some cURL request , some converting converting functions (Bytes to MB,GB) or some functions when we are using apis to return json format .
Liike we have some other methods of using resuable code like Traits , functions in models but when you have to use these methods you first have to initialise like if we have traits , so to use them ( we have to intialize and call the method use and same in model we have to initialize in the controller ) but what if we want use that code in Blade file ......
So here we use a helper or common function which is used in every single file in larvel. Make a folder structure like this app/Common/helper.php
so here we make manually a fiile name helper.php inside Common folder now we define it in autoload files inside composer.json in root directory don't replace the whole code
just add the helper directory in autoload funtion Copy
and hit composer dump-autoload Copy
add the following code in helper.php Copy
call the function in any controller Copy