From ce5d9802cb0a051c7e58cfeb634e41977ecd144a Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 8 Jun 2016 21:40:02 +0200 Subject: [PATCH] Implement delete event. Update create event to send full post. --- Repositories/Eloquent/EloquentPostRepository.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Repositories/Eloquent/EloquentPostRepository.php b/Repositories/Eloquent/EloquentPostRepository.php index 90d51f8..9b97ea0 100644 --- a/Repositories/Eloquent/EloquentPostRepository.php +++ b/Repositories/Eloquent/EloquentPostRepository.php @@ -4,6 +4,7 @@ use Modules\Blog\Entities\Post; use Modules\Blog\Entities\Status; use Modules\Blog\Events\PostWasCreated; +use Modules\Blog\Events\PostWasDeleted; use Modules\Blog\Events\PostWasUpdated; use Modules\Blog\Repositories\Collection; use Modules\Blog\Repositories\PostRepository; @@ -56,11 +57,18 @@ public function create($data) $post->tags()->sync(array_get($data, 'tags', [])); - event(new PostWasCreated($post->id, $data)); + event(new PostWasCreated($post, $data)); return $post; } + public function destroy($model) + { + event(new PostWasDeleted($model->id, get_class($model))); + + return $model->delete(); + } + /** * Return all resources in the given language *