lundi 17 février 2020

Laravel with Arabic Slugs

i'm using Laravel 6 to build a blog application and the language of this app is Arabic but there is a problem with slug ,it looks like that Laravel doesn't support Arabic.

any idea to fix this?

Controller

public function post($slug)
{
    $post = Post::where('slug',$slug)->first();
    return view('content.post',compact('post'));
}

Store Method

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 = Str::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/2SxuQmb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire