Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nathanaelphilip/84e0c061e0ad2826cbe59f53dc349151 to your computer and use it in GitHub Desktop.
Save nathanaelphilip/84e0c061e0ad2826cbe59f53dc349151 to your computer and use it in GitHub Desktop.
add attribute to model
protected $appends = array(
'date_range',
'share_url'
);
public function getShareUrl()
{
$starts_at = Carbon::parse($this->starts_at);
$share_url = '/calendar/' . $starts_at->year . '/' . $starts_at->month . '/#event/' . $this->id;
return $this->attributes['share_url'] = $share_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment