Sign Up

Sign In

Forget Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask question.

Developers Map

Create Custom Helper in Laravel

  • 1

Cutsom helper is used to call a function in multiple file at a time.It Is very simpe and easy method to call a function in your web appllication.

Use Below Code :
Step 1 : Create a folder Helpers  in app directory.
Step 2 : Then Create a helper file like CustomHelper.php in Helpers  folder.
Step 3 :  after this copy below code and paste that in your file

namespace App\Helpers;
class CustomHelper  {
public static function YourFunctionName()
{
echo “hello world”;
}
}

Step 4 : then open your app/config.php file use below code.

‘aliases’ => [
.
CustomHelper’ => App\Helpers\CustomHelper::class
],

Step 5 :  after all this use below code in your controller.

\CustomHelper::YourFunctionName();

Leave an answer

Leave an answer

Browse