Creating Helper Function in Laravel 6 Example | Pakainfo

USA Videos
Jan 11 · 2 min read

Today, We want to share with you Creating Helper Function in Laravel 6.In this post we will show you Laravel 6 Create Custom Helper Function, hear for Creating Your Own PHP Helpers in a Laravel Project we will give you demo and example for implement.In this post, we will learn about how to call helper function in laravel blade with an example.

Creating Helper Function in Laravel 6

There are the Following The simple About Helpers — Laravel — The PHP Framework For Web Artisans Full Information With Example and source code.

As I will cover this Post with live Working example to develop Best Practices for Custom Helpers in Laravel 6, so the Creating Your Own PHP Helper Functions In Laravel 6 is used for this example is following below.

Step 1: Create a Helpers

<?php use Carbon\Carbon; if (!function_exists('expire_time_zone')) { function expire_time_zone(string $date) { return Carbon::parse($date, config('app.expire_time_zone'))->format('Y-m-d\TH:i:s'); } } if (!function_exists('expire_time_zone')) { function getConverThumbImage($img_url) { $base_url = config('app.url'); if (trim($img_url) == "") { return $base_url . '/api/uploads/default-150x150.png'; } $file_img = pathinfo($img_url); if (is_array($file_img)) { return $file_img['dirname'] . '/' . $file_img['filename'] . '-400x400.' . $file_img['extension']; } else { return $img_url; } } }

Step 2: create a Laravel Service Provider


<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; class MyAppServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot() { // } /** * Register the application services. * * @return void */ public function register() { // require_once app_path() . '/Helpers.php'; } }

Step 3: Register your Service Provider

'providers' => [ ... App\Providers\MyAppServiceProvider::class, ],

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about create helper function in laravel.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Originally published at on January 11, 2020.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade