laravel-helper

After upgrading Laravel from 5.6 to 6.0, Call to undefined str_random() function not working

好久不见. 提交于 2020-06-08 05:00:30
问题 I have upgraded Laravel from 5.6 to 6.0. Previously, default helper functions were running fine on the controllers, but now it says " undefined ." In my controller, I have used the following. $filename = str_random(12); I am getting the following error. message: "Call to undefined function App\Http\Controllers\str_random()" I have also used the random() function, and it's saying the same thing. Can somebody please guide me on what to do?. I have run commands like: composer dump-autoload But I

“Call to undefined function str_slug()” in Laravel 6.0

旧巷老猫 提交于 2019-12-23 06:49:15
问题 I've upgraded my laravel 5.8 project to 6.0. It has upgraded successfully but when I'm trying to run the project or installing another package to my project it is giving me error named as "Call to undefined function str_slug()" in session.php. I don't know why.... Call to undefined function str_slug() 回答1: If you have gone through the upgrade guide then you must know that String and Array Helpers are removed from Core Framework https://laravel.com/docs/6.0/upgrade#helpers https://github.com

Best Practices for Laravel 4 Helpers and Basic Functions?

本秂侑毒 提交于 2019-11-27 05:46:23
I'm trying to understand the best place to put a global function in Laravel 4. For example, date formatting. I don't think making a facade is worth it as facades are too modular. I've read articles about creating a library folder and storing classes there but that also seems like a lot for a simple function. Shouldn't a 'tool' like this be available in Blade templates? What are the best practices for something like this and how do I make it available to Blade templates? The ugly, lazy and awful way: At the end of bootstrap/start.php , add an include('tools.php') and place your function in that

Best Practices for Laravel 4 Helpers and Basic Functions?

那年仲夏 提交于 2019-11-26 11:44:38
问题 I\'m trying to understand the best place to put a global function in Laravel 4. For example, date formatting. I don\'t think making a facade is worth it as facades are too modular. I\'ve read articles about creating a library folder and storing classes there but that also seems like a lot for a simple function. Shouldn\'t a \'tool\' like this be available in Blade templates? What are the best practices for something like this and how do I make it available to Blade templates? 回答1: The ugly,

Best Practices for Custom Helpers in Laravel 5

ぃ、小莉子 提交于 2019-11-26 05:41:05
问题 I would like to create helper functions to avoid repeating code between views in Laravel 5: view.blade.php <p>Foo Formated text: {{ fooFormatText($text) }}</p> They\'re basically text formatting functions. Where and how can I create a file with these functions? 回答1: Create a helpers.php file in your app folder and load it up with composer: "autoload": { "classmap": [ ... ], "psr-4": { "App\\": "app/" }, "files": [ "app/helpers.php" // <---- ADD THIS ] }, After adding that to your composer