Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Last active December 18, 2015 17:09
Show Gist options
  • Save dhrrgn/5816331 to your computer and use it in GitHub Desktop.
Save dhrrgn/5816331 to your computer and use it in GitHub Desktop.
<?php
public function update($id, $title, $content, $slug, array $tags, $active, DateTime $publish_date)
{
$post = $this->find($id);
if (Config::get('wardrobe.cache'))
{
// Forget the old cache
Cache::forget('post-'.$post->slug);
}
$post->fill(compact('title', 'content', 'slug', 'active', 'publish_date'))->save();
$post->tags()->delete();
$post->tags()->createMany($this->prepareTags($tags));
return $post;
}
<?php
public function getParsedContentAttribute()
{
if (Config::get('wardrobe.cache'))
{
$self &= $this;
return Cache::rememberForever('post-'.$this->attributes['slug'], function() use ($self)
{
return md($self->attributes['content']);
});
}
return md($this->attributes['content']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment