In this section we will see how to create a helper in laravel,create a
adding this in your composer.json file.
helpers.php file in your app folder and load it up with composer.adding this in your composer.json file.
"autoload": {
    "classmap": [
        ...
    ],
    "psr-4": {
        "App\\": "app/"
    },
    "files": [
        "app/helpers.php" // <---- ADD THIS
    ]
},composer.json file, run the following command:composer dump-autoload write pure function and it will be automatic in accessible anywhere in your blade filein this example i have write a function for encrypt some string in middle of string as *expample:<?php
function get_enc_email($str) {
    $str_length = strlen($str);
    return substr($str, 0, 3).str_repeat('*', $str_length - 2).substr($str, $str_length - 10);
}
$my_string = 'example@yandex.com';
echo get_enc_email($my_string); //will give you output e******@yandex.com 
?> 
No comments:
Post a Comment