Question: I seem to be using the check `let title = options.title ? options.title : null;` and wondering if there is a nicer maybe minmized version of doing this? I remember seeing an ES6 version but I just can't remember what it is.

**JS**

```
this.options = options;
this.model = new Model({
        title: this.options.title ? this.options.title : null,
        message: this.options.message ? this.options.message : null,
        list: this.options.list ? this.options.list : null,
        errors: this.options.errors ? this.options.errors : null,
        innerHTML: this.options.html ? this.options.html : null
    });

```

Answer: 
Thanks for the comments and answers.

First, i was making a mistake in the first part of my question. I did a custom validation in Laravel on a unique slug, without website id. I changed this and it's works fine.

```
'slug' => 'unique:pages,slug,NULL,pages,website_id,'.\Request::get('website_id'),

```

The model needs the function "scopeWithUniqueSlugConstraints" to check for multiple columns before generating.

```
public function website()
{
    return $this->belongsTo('App\Models\Website');
}

public function scopeWithUniqueSlugConstraints(Builder $query, Model $model, $attribute, $config, $slug)
{
    $website = $model->website;
    return $query->where('website_id', $website->getKey());
}

```

In my pageController (front-end) I call the page with:

```
Page::whereSlug($slug)->where('website_id', '=', $website_id)->first();

```
> 
> Alternatively you can use str\_slug if you just want to sluggify
> 
> 
> 

```
$title = str_slug("Laravel 5 Framework", "-");
//gives laravel-5-framework

```

MODEL

```
class News 
{
    protected $fillable = [
        'title', 'body', 'slug',
    ];
}

```

CONTROLLER

```
public function store(Request $request) 
    {
    $news = new News();
    $news->title = $request->input("title");
    $news->body = $request->input("body");
    $news->slug = str_slug($request->input("title"));//you can append current date and time to make unique slug

    $news->save();

}

/**
 * Display the specified news by slug.
 *
 * @param  $slug
 * @return Response
 */
public function ShowbySlug($slug)
{
    $news = News::where("slug",'=',$slug);

    return view('news.show', compact('news'));
}

```

ROUTE

```
Route::get("news/{slug}","NewsController@ShowbySlug");

```