public function actionIndex() { //$searchModel = new Type; //$dataProvider = $searchModel->pageAll(Yii::$app->request->queryParams); //return $this->render('index', [ // 'dataProvider' => $dataProvider, //]); $model = new Type(); $arr['obj'] = $model->getAll(); $arr['f_name'] = $model->getAll(['f_id' => "0"]); return $this->renderPartial('index', $arr); }
static function find($search_id) { $found_type = null; $types = Type::getAll(); foreach ($types as $type) { $type_id = $type->getId(); if ($type_id == $search_id) { $found_type = $type; } } return $found_type; }
function test_deleteAll() { //Arrange $descript = "Event Keepsakes"; $descript2 = "Antiques"; $test_Type = new Type($descript); $test_Type->save(); $test_Type2 = new Type($descript2); $test_Type2->save(); //Act Type::deleteAll(); $result = Type::getAll(); //Assert $this->assertEquals([], $result); }
}); $app->get('/trainers/:id/badges', function ($id) use($app) { $trainer = Trainer::getById($id); sendResponse($trainer->getBadges()); }); $app->get('/gyms', function () use($app) { sendResponse(Gym::getAll()); }); $app->get('/gyms/:id', function ($id) use($app) { $gym = Gym::getById($id); sendResponse($gym->serialize()); }); $app->get('/gyms/:id/leader', function ($id) use($app) { $gym = Gym::getById($id); sendResponse($gym->getLeader()->serialize()); }); $app->get('/types', function () use($app) { sendResponse(Type::getAll()); }); $app->get('/types/:id', function ($id) use($app) { $type = Type::getById($id); sendResponse($type->serialize()); }); $app->get('/badges', function () use($app) { sendResponse(Badge::getAll()); }); $app->get('/badges/:id', function ($id) use($app) { $badge = Badge::getById($id); sendResponse($badge->serialize()); }); $app->run();
}); $app->get("/types", function () use($app) { return $app['twig']->render('types.html.twig', array('types' => Type::getAll())); }); $app->get("/searches", function () use($app) { return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll())); }); $app->post("/collections", function () use($app) { $collection = new Collection($_POST['thing']); $collection->save(); return $app['twig']->render('collections.html.twig', array('collections' => Collection::getAll())); }); $app->post("/types", function () use($app) { $type = new Type($_POST['descript']); $type->save(); return $app['twig']->render('types.html.twig', array('types' => Type::getAll())); }); $app->post("/searches", function () use($app) { $search = new Search($_POST['find']); $search->save(); return $app['twig']->render('searches.html.twig', array('searches' => Search::getAll())); }); $app->post("/delete_collections", function () use($app) { Collection::deleteAll(); return $app['twig']->render('delete_collections.html.twig'); }); $app->post("/delete_types", function () use($app) { Type::deleteAll(); return $app['twig']->render('delete_types.html.twig'); }); return $app;
function getSelect() { $results = Type::getAll("title"); foreach ($results as $row) { $temp[] = array("value" => $row['id'], "label" => stripslashes($row['title'])); } return $temp; }