Skip to content

Instantly share code, notes, and snippets.

@clarkf
Created January 18, 2014 01:40
Show Gist options
  • Select an option

  • Save clarkf/8484997 to your computer and use it in GitHub Desktop.

Select an option

Save clarkf/8484997 to your computer and use it in GitHub Desktop.
<?php
$post = Post::find($id);
$post->title = "Hello World!";
var_dump($post->slug); // "hello-world"
<?php
class Post extends Eloquent
{
protected $fillable = array(
'title',
'slug'
);
public function setTitleAttribute($value)
{
$this->slug = Str::slug($value);
$this->attributes['title'] = $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment