Created
September 12, 2014 13:32
-
-
Save mul14/ab5f96264360f383dfa1 to your computer and use it in GitHub Desktop.
Laravel - Automatic create slug when saving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App; | |
use Illuminate\Support\Str; | |
use Illuminate\Database\Eloquent\Model; | |
class Article extends Model { | |
public function setSlugAttribute($value) | |
{ | |
$this->attributes['slug'] = Str::slug($value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment