Created
April 30, 2017 16:08
-
-
Save Mombuyish/a7f821541a2d1579d91a8fa4148d7c2c to your computer and use it in GitHub Desktop.
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 | |
public function create($attributes) | |
{ | |
//用 laravel relations 的方式建立文章 | |
//也可以透過 repository 的方式做建立或將此搬遷過去 | |
$post = auth()->user()->posts()->create($attributes); | |
//設定 slug, 加入標籤 | |
$post->slugify()->tag($attributes['tag']); | |
//通知訂閱用戶 | |
event(new Subscribers); | |
return $post; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment