D
D
dk-web2015-11-15 21:31:04
Laravel
dk-web, 2015-11-15 21:31:04

How to correctly form slug in laravel 5.1?

I'm making a news module.
Three simple fields:
id (do not count)
title
slug
content The title is
clear... The
content is even clearer
But the notorious slug? How to generate it? I'm afraid that if I tell the customer - drive it in with your hands - v-raoine-proshel-subbotnik - they won't understand me very much ...
How is this even implemented?
In the helper I see a function - str_slug, but mentally I still don't understand where to fasten it.
I would be grateful for advice.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
entermix, 2015-11-15
@dk-web

$slug = Str::slug($title);
chrishayes.ca/blog/code/laravel-4-generating-uniqu...

E
Eugene, 2015-11-15
@Nc_Soft

In saving hook do $this->slug = str_slug($this->title)
laravel.com/docs/5.1/eloquent#events

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question