Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

This doesn't have anything to do with Eloquent. You should extract this replacement behaviour to its own dedicated class. The way you are using str_replace is so unmaintainable. Maybe you could use a hash array, at least it would be much easier to read and update later.

$replacements = [
    '-' => '',
    '!' => '',
    // etc...
];
Last updated 2 years ago.
0

Why you are not using

Str::slug()

?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Metrakit metrakit Joined 25 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.