Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 3 months 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 3 months ago.
0

Why you are not using

Str::slug()

?

Last updated 3 months ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

Metrakit Metrakit metrakit Joined 25 May 2014

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.