/** * Bootstrap the application events. * * @return void */ public function boot() { // custom namespace $this->package('alexwenzel/laravel-commentary', 'laravel-commentary'); // comment list composer View::composer('laravel-commentary::comment-list', function ($view) { $entity = $view->entity; $comments = Comment::where('entity', $entity)->where('status', Comment::statusApproved)->orderBy('created_at', 'desc')->get(); $view->with('comments', $comments); }); }
/** * Actionhandler for posted comment forms * @param array $data * @return Comment */ public function comment_post($data) { $comment = $this->model->create($data); Event::fire('laravel-commentary.comment-posted', array($comment)); return $comment; }