i'm building an Arabic Slug system form my Blog App
when i add a new Slug i got this error
preg_replace(): Compilation failed: invalid range in character class at offset 11
controller
public function slug($string, $separator = '-') {
if (is_null($string)) {
return "";
}
$string = trim($string);
$string = mb_strtolower($string, "UTF-8");;
$string = preg_replace("/[^a-z0-9_\s-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]#u/", "", $string);
$string = preg_replace("/[\s-]+/", " ", $string);
$string = preg_replace("/[\s_]/", $separator, $string);
return $string;
}
public function store(Request $request)
{
$this->validate($request, array(
'title' => 'required|max:255',
'slug' => 'required|min:3|max:255|unique:posts',
'body' => 'required',
));
$post = new Post;
$post->title = $request->input('title');
$post->slug = $this->slug($request->slug);
$post->body = $request->input('body');
$post->save();
return redirect('admin/posts')->with('success', 'post is successfully saved');
}
Route
Route::get('post/{slug}', 'PagesController@post')->name('post.show');
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3bNZ8Zl
via IFTTT
Aucun commentaire:
Enregistrer un commentaire