AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Phpstorm laravel facade support12/28/2023 If you have notice then you see there that we have extends our parent class Facade.php which we will see after this.And inside static function getFacadeAccessor() we have resolve a class instance from the container by doing app(HashManager::class) & return it. Then let's dive into our Hash.php file which is inside App\App\Support\Facade and make protected static function getFacadeAccessor() inside it. This is how we bind our HashMananger class and we pass our argument as we have declared the $valueas parameter in _construct($value)method in HashManager.php and return it.One of the advantage of this binding is we don't need to make another new instance of class for accessing the properties and methods of class in any other place once we have bind it in service container and return it.If you are not getting what i m saying, no worries !! we are going to see it soon which makes you crystal clear. Now, let's move towards HashServiceProvider.php and inside register() method bind our HashManager.php class which ultimately return new instance of the class. It was all about hashing the given data and second public function check($value,$hashed_value) which accepts two parameters,first one is $valuewhich is plain text and second $hashed_value which is hashed value of your $value and after passing those arguments of these parameters inside password_verify() method, it verify whether they matched or not and finally return boolean value based on true or false statement. Similarly create another file HashManger.php but outside of Facade folder inside Support.This is how our directory looks like:įirstly, let's dive into HashManager.php file where we have implemented logic of hashing the given data.Īs you can see it's just a php class where at first we have decleared protected $algo which generally refers to algorithm and inside _construct($algo) method we have assign to its parameter.Then we make public function make($value) which accept parameter as value and finally hashed the value which is as passed inside password_hash() method and returned hashed value. App\Providers\BroadcastServiceProvider::class,Īpp\Providers\EventServiceProvider::class,Īpp\Providers\RouteServiceProvider::class,Īpp\Providers\HashServiceProvider::class, // in this wayĪfter that let's create Support folder inside App directory and inside Support directory, create another folder called Facade which will contain two files viz. On process of registration of any kind of form which contains password especially, we encrypt password data which come from form for security.For encryption,there is a method in laravel which is implemented this way: [Īpp\Providers\AppServiceProvider:: class,Īpp\Providers\AuthServiceProvider::class, If you are Laravel developer or have worked in laravel already, I am pretty sure that you must have heard about Laravel Facade.Not only heard but you have implemented various methods in laravel using facade class.
0 Comments
Read More
Leave a Reply. |