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 Most Useful Command's Lists With Parameters Example
- How to Get Browser Name and Version in Laravel
- laravel cache clear command
- How To File Upload AWS s3 Bucket In Laravel 9
- Error : You need to install the imagick extension to use this back end
- Laravel Country State City Dropdown Using AJAX
- How to Generate PDF File Using DomPDF In Laravel 9 Example
- Unique violation: 7 ERROR: duplicate key value violates unique constraint "users_pkey" DETAIL: Key (id)=(1) already exists.
- Laravel 6 CRUD Operation
- How To Use Where Clause With Two Fields Of The Same Table Examples