public function store(ItemStoreRequest $request, Dispatcher $event)
{
$user = $this->userService->getCurrentUser();
$object = app('stdClass');
$object->user_id = $user->id;
$object->open_item_id = $this->itemService->createOpenItemId();
$object->title = \Input::get('title');
$object->body = \Input::get('body');
$object->published = \Input::get('published');
$item = $this->itemService->create($object);
$result = $this->itemService->createHistory($item, $user);
$tags = \Input::get('tags');
if (!empty($tags)) {
$tag_names = explode(",", $tags);
$tag_ids = $this->tagService->getTagIdsByTagNames($tag_names);
$item = $this->itemService->getById($item->id);
$this->tagService->syncTags($item, $tag_ids);
}
// fire CreateEvent
// TODO: do not create instance in controller method
$event->fire(new CreateEvent($object->open_item_id, (int) $user->id));
return \Redirect::route('items.show', [$item->open_item_id]);
}