How to make strtolower and space for - in Laravel

Hi guys newbie so I really need your help I want to link like this:

https://floristshop.msi-staging.tk/store/4/bunga-indah

but i got this:

https://floristshop.msi-staging.tk/store/4/Bunga%20Indah

and this is my code:

 <p>
  @foreach($stores as $store)
    <a href="{{ env('FRONTEND_URL') . "/store/$store->id/$store->name"}}"><label>{{ env('FRONTEND_URL') . "/store/$store->id/$store->name"}}  </label></a>
  @endforeach
 </p>

      

I really need help: D

+3


source to share


1 answer


Laravel provides a very good helper for bullet creation.

you can try str_slug('Laravel 5 Framework', '-');

to get the results you want.



  @foreach($stores as $store)
    <a href="{{ env('FRONTEND_URL') . "/store/$store->id/$store->name"}}"><label>{{ env('FRONTEND_URL') . "/store/$store->id/".str_slug($store->name)}}  </label></a>
  @endforeach

      

I hope this helps

+4


source







All Articles