Wednesday, October 31, 2018

Laravel 5.5 create custom facade example from scratch

In this article, here i will give you step by step guide to create a custom facade in Laravel 5.5 application. You can also learn how to create custom service provider and custom aliases for your class in laravel 5.
Ok So, We may need to create custom facade for creating general helper, some method that always use in whole application like here in example, i created getUserImage() method for getting pull path of user image, Here i will check file is exist or not on following on path then return full path. But it is as an example, So that way you can create your method that you reuse in whole application.
So, Just follow few step to create custom facades in Laravel 5.5 application

How To Create Custom Helper In Laravel 5.5

Today in this article we are share with you how to make custom helper in laravel. you need some time make your own custom helper for some repeted code or logic. like get fullname of current user. convert currency helper, number formate etc...
So, you can create above all logic in one time in one helper function then you can use this custom helper function in everywere in laravel application. you use this custom helper in your laravel blade file and also use in any controller.
in this article we are make one custom helper which get current user full name and how to use this custom helper in blade file and laraval controller.
Please follow step to create custom helper in laravel application

How to Create a Laravel Helper

As we discussed earlier, there are plenty of helpers available in the core of the Laravel framework. They are grouped together based on the functionality they provide. Here’s a list of helper groups.
Helpers in this group provide functionality to manipulate array elements. More often than not, you're in the situation where you want to perform different operations on array elements. So this is the place where you should look first to see if what you're looking for already exists.
I find helpers in this category most useful. They return the fully qualified path of different directories like app, storage, config, and the like. I bet you're using most of these helpers already in your Laravel application.
String manipulation is something inevitable in your day-to-day application development. Although there are plenty of string manipulation functions provided by PHP itself, you'll find a few more useful goodies in this section.
You'll find very few in this category, but they are used throughout the application. They are used to generate route, asset, and form action URLs.
This category contains helpers that provide a variety of functionalities ranging from logging to debugging and many more.