public function destroy($id) { $questions = Questions::find($id); $questions->delete(); Session::flash('message', 'Successfully deleted the Questions!'); return Redirect::to('questions'); }
public function indexAction() { $response = new ApiResponse(); if ($this->request->isGet()) { $limit = $this->request->get('limit'); $page = $this->request->get('page'); $questions = Questions::find(array("order" => "created_at DESC")); $paginator = new PaginatorModel(array("data" => $questions, "limit" => $limit, "page" => $page)); $page = $paginator->getPaginate(); $res = []; foreach ($page->items as $item) { $user = Users::findFirstById($item->users_id); $item->user_name = $user->username; $item->user_avatar = $user->avatar; $res[] = $item; } $response->setResponse($res, count($questions)); return $response; } else { $response->setResponseError('Wrong HTTP Method'); } return $response; }
public function indexAction() { $this->view->questions = Questions::find(); }