/** * getdata * @return type */ public function getData() { return \Datatable::collection(Comment::All())->searchColumns('name', 'email', 'comment', 'created')->orderColumns('name')->addColumn('name', function ($model) { return $model->name; })->addColumn('email', function ($model) { return $model->email; })->addColumn('website', function ($model) { return $model->website; })->addColumn('comment', function ($model) { return $model->comment; })->addColumn('status', function ($model) { $status = $model->status; if ($status == 1) { return '<p style="color:blue"">' . \Lang::get('lang.published'); } else { return '<p style="color:red"">' . \Lang::get('lang.not_published'); } })->addColumn('Created', function ($model) { return TicketController::usertimezone(date($model->created_at)); })->addColumn('Actions', function ($model) { return '<a href=comment/delete/' . $model->id . ' class="btn btn-danger btn-xs">' . \Lang::get('lang.delete') . '</a> <a href=published/' . $model->id . ' class="btn btn-warning btn-xs">' . \Lang::get('lang.publish') . '</a>'; })->make(); }
/** * To insert the values to the comment table * @param type Article $article * @param type Request $request * @param type Comment $comment * @param type Id $id * @return type response */ public function postComment($slug, Article $article, CommentRequest $request, Comment $comment) { $article = $article->where('slug', $slug)->first(); $id = $article->id; $comment->article_id = $id; if ($comment->fill($request->input())->save()) { return Redirect::back()->with('success', 'Your comment posted'); } else { return Redirect::back()->with('fails', 'Sorry not processed'); } }
/** * Delete an Agent by id * @param type $id * @param type Article $article * @return Response */ public function destroy($slug, Article $article, Relationship $relation, Comment $comment) { /* delete the selected article from the table */ $article = $article->where('slug', $slug)->first(); //get the selected article via id //dd($article); $id = $article->id; $comments = $comment->where('article_id', $id)->get(); if ($comments) { foreach ($comments as $comment) { $comment->delete(); } } $relation = $relation->where('article_id', $id)->first(); if ($relation) { $relation->delete(); } if ($article) { if ($article->delete()) { return Redirect::back()->with('success', 'Article Deleted Successfully'); } else { return Redirect::back()->with('fails', 'Article Not Deleted'); } } else { return Redirect::back()->with('fails', 'Article can Not Deleted'); } }