Now let we know how to solve Call to undefined function str_slug() issue in laravel 6. All string and array function like str_words, str_random(), str_limit(), array_sort(), array_first(), array_only etc call as laravel 6 Call to undefined function.
Now you can not use an array and string helpers because laravel 6 removed helpers function from the new laravel 6.
Here at a time, 2 solutions are available from resolve that issue like this way.
use Illuminate\Support\Str; use Illuminate\Support\Arr;
Solution 1
routes/web.php
Route::get('slug',function(){
$slug = Str::slug('we are from webappfix community.');
dd($slug);
});
In this 2 Solution is that you can use the old method to call laravel string and array function.
Solution 2
Install laravel helper package followirng this command
composer require laravel/helpers
after installed that package you can use the old method to call helpers fucntion
Route::get('slug', function () {
$slug = str_slug('we are from webappfix');
dd($slug);
});
You can use other string and array function like this ways.
Arr::collapse(); Arr::last(); Arr::first(); Arr::prepend(); Arr::except(); Arr::divide(); Arr::pluck(); Arr::random(); Arr::forget(); Arr::get(); Arr::has(); Arr::sortRecursive(); Arr::add(); Arr::only(); Arr::dot(); Arr::pull(); Arr::wrap(); Arr::set(); Arr::flatten(); Arr::sort(); Arr::where();
Str::containsAll(); Str::camel(); Str::finish(); Str::contains(); Str::before(); Str::kebab(); Str::after(); Str::orderedUuid(); Str::is(); Str::random(); Str::plural(); Str::endsWith(); Str::replaceArray(); Str::limit(); Str::singular(); Str::replaceFirst(); Str::replaceLast(); Str::startsWith(); Str::snake(); Str::start(); Str::slug(); Str::words(); Str::title(); Str::uuid(); Str::studly();
I have tryed in this tutorial to solve easily. string and array function issues.
thank you so much for reading this post. I hope it will helpful for you.
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- Laravel 9 Google Drive File Upload/Store Tutorial.
- Laravel 9 Dropzone Multiple File Upload Example
- Laravel Zaakpay Payment Gateway Integration Tutorial Example
- Web Push Notification Send Using Firebase Cloud Messaging In Laravel Tutorial Include Demo Example
- Create Custom Route File With New Service Provider Laravel 8 9
- Laravel 6 validation with error message
- Laravel Logs Viewer Integration
- Arr::accessible() | Laravel Helper Function
- Default index.php Root Path Change And Remove Public From The Url
- How to Send Mail using PHPMailer in Laravel?