public function display() { $allClients = Client::getAll(); $upcomingTasks = Task::getRecent(); $pastDue = Task::pastDue(); return View::make('clients_page')->with('allClients', $allClients)->with('pastDue', $pastDue)->with('upcomingTasks', $upcomingTasks); }
function delete() { $clients = Client::getAll(); foreach ($clients as $client) { if ($client->getStylistId() == $this->getId()) { $client->delete(); } } $GLOBALS['DB']->exec("DELETE FROM stylists WHERE id = {$this->getId()};"); }
static function find($search_id) { $found_client = null; $all_clients = Client::getAll(); foreach ($all_clients as $client) { if ($client->getId() == $search_id) { $found_client = $client; } } return $found_client; }
static function find($search_id) { $found_client = null; $clients = Client::getAll(); foreach ($clients as $client) { $client_id = $client->getId(); if ($client_id == $search_id) { $found_client = $client; } //end of if } //end of foreach return $found_client; }
function test_getAll() { //Arrange $client_name = "Ted"; $stylist_id = 1; $test_client = new Client($client_name, $stylist_id); $test_client->save(); $client_name2 = "Mae"; $stylist_id2 = 2; $test_client2 = new Client($client_name2, $stylist_id2); $test_client2->save(); //Act $result = Client::getAll(); //Assert $this->assertEquals([$test_client, $test_client2], $result); }
function testDelete() { //Arrange $name = "Jackie"; $test_stylist = new Stylist($name); $test_stylist->save(); $name = "Sandra Jane"; $phone = "542-334-0984"; $style_choice = "The Rachel"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $phone, $style_choice, $stylist_id); $test_client->save(); $name2 = "Jordy Duran"; $phone2 = "239-094-0281"; $style_choice2 = "Bowl Cut"; $test_client2 = new Client($name2, $phone2, $style_choice2, $stylist_id); $test_client2->save(); //Act $test_client->delete(); //Assert $this->assertEquals([$test_client2], Client::getAll()); }
function test_delete() { //Arrange $stylist_name = "bob"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $client_name = "joe"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id, $stylist_id); $test_client->save(); $client_name2 = "jerry"; $test_client2 = new Client($client_name2, $id, $stylist_id); $test_client2->save(); //Act $test_client->delete(); //Assert $this->assertEquals([$test_client2], Client::getAll()); }
function testDelete() { //Arrange $id = null; $name = "Martha Stewart"; $phone = "(888) 888-8888"; $next_visit = "2015-09-06"; $stylist_id = 1; $test_client = new Client($id, $name, $phone, $next_visit, $stylist_id); $test_client->save(); $name2 = "Jennifer Lopez"; $phone2 = "(609) 999-9999"; $next_visit2 = "2015-10-12"; $stylist_id2 = 2; $test_client2 = new Client($id, $name2, $phone2, $next_visit2, $stylist_id2); $test_client2->save(); //Act $test_client->delete(); //Assert $result = Client::getAll(); $this->assertEquals([$test_client2], $result); }
function testDeleteStylistClients() { //Arrange $stylist_name = "Bob"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $client_name = "Joe"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id, $stylist_id); $test_client->save(); //Act $test_stylist->delete(); //Assert $this->assertEquals([], Client::getAll()); }
function test_client_delete() { //Arrange $name = "Vidal Sassoon"; $test_stylist = new Stylist($name); $test_stylist->save(); $name2 = "Sweeney Todd"; $test_stylist2 = new Stylist($name2); $test_stylist2->save(); $name3 = "Mr. T"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name3, $stylist_id, null); $test_client->save(); $name4 = "Mrs. T"; $stylist_id2 = $test_stylist2->getId(); $test_client2 = new Client($name4, $stylist_id2, null); $test_client2->save(); //Act $test_client->delete(); //Assert $this->assertEquals([$test_client2], Client::getAll()); }
$client->save(); $stylist = Stylist::find($stylist_id); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'client' => $stylist->getClient())); }); $app->post("/stylists", function () use($app) { $stylist = new Stylist($_POST['name']); $stylist->save(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); $app->post("/delete_stylists", function () use($app) { //Clients::deleteAll(); Stylist::deleteAll(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); $app->post("/delete_client", function () use($app) { $category_id = $_POST['stylist_id']; Client::delete($stylist_id); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); $app->get("/all_clients", function () use($app) { return $app['twig']->render('all_clients.html.twig', array('clients' => Client::getAll(), 'stylists' => Stylist::getAll())); }); $app->post("/client", function () use($app) { $name = $_POST['name']; $stylist_id = $_POST['stylist_id']; $client = new Client($name, $stylist_id); $client->save(); $stylist = Stylist::find($stylist_id); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'clients' => Client::getAll())); }); return $app;
function testDeleteStylistClients() { //Arrange $name = "Erin"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "George"; $id = null; $test_client = new Client($name, $stylist_id); $test_client->save(); //Act $test_stylist->delete(); //Assert $this->assertEquals([], Client::getAll()); }
function test_deleteAll() { //Arrange $name = "Barbra Stylist"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "George"; $id = null; $stylist_id = $test_stylist->getId(); $test_Client = new Client($name, $stylist_id, $id, $visits, $description); $test_Client->save(); $name2 = "Max"; $id2 = null; $stylist_id2 = $test_stylist->getId(); $visits2 = 3; $test_Client2 = new Client($name2, $stylist_id2, $id2, $visits2, $description); $test_Client2->save(); //Act Client::deleteAll(); //Assert $result = Client::getAll(); $this->assertEquals([], $result); }
$escaped_array = array(); foreach ($input_associative_array as $key => $value) { $escaped_array[$key] = preg_quote($value, "'"); } return $escaped_array; } //////////////////////////// Routes // Landing page. [R]ead $app->get("/", function () use($app) { return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); // [D]elete all stylists and clients $app->delete("/", function () use($app) { Stylist::deleteAll(); Client::deleteAll(); return $app['twig']->render('index.html.twig', array('clients' => Client::getAll())); }); // [C]reate Stylist, display all stylists $app->post("/stylists", function () use($app) { $escaped_inputs = escapeCharsInArray($_POST); $new_stylist = new Stylist($escaped_inputs['name'], $escaped_inputs['phone'], $escaped_inputs['specialty'], $escaped_inputs['weekends']); $new_stylist->save(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); // [R]ead one particular Stylist $app->get("/stylists/{id}", function ($id) use($app) { $stylist = Stylist::find($id); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'clients' => $stylist->getClients())); }); // [U]pdate a particular Stylist $app->patch("/stylists/{id}", function ($id) use($app) {
function testDelete() { //Arrange $id = null; $client_name = "Nico"; $stylist_id = 1; $test_client = new Client($id, $client_name, $stylist_id); $test_client->save(); $client_name2 = "Al"; $stylist_id2 = 2; $test_client2 = new Client($id, $client_name2, $stylist_id2); $test_client2->save(); //Act $test_client->delete(); //Assert $result = Client::getAll(); $this->assertEquals([$test_client2], $result); }
function test_client_getStars() { //Arrange $style = "Thai"; $test_cuisine = new Client($style); $test_cuisine->save(); $name = "Pok Pok"; $category_id = $test_cuisine->getId(); $stars = 5; $test_client = new Client($name, $category_id, null, $stars); $test_client->save(); $name2 = "Dicks"; $stars2 = 3; $category_id2 = $test_cuisine->getId(); $test_client2 = new Client($name2, $category_id, null, $stars2); $test_client2->save(); //Act $result = Client::getAll(); //Assert $this->assertEquals(5, $result[0]->getStars()); }
function testDeleteStylistClient() { //Arrange $stylist_name = "Bilbo Baggins"; $test_stylist = new Stylist($stylist_name, $id = null); $test_stylist->save(); $client_name = "The Necromancer"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id = null, $stylist_id); $test_client->save(); //Act $test_stylist->delete(); //Assert $this->assertEquals([], Client::getAll()); }
function test_stylist_delete() { $style = "Thai"; $test_stylist = new Stylist($style); $test_stylist->save(); $style2 = "burgers"; $test_stylist2 = new Stylist($style2); $test_stylist2->save(); $name = "Pok Pok"; $category_id = $test_stylist->getId(); $test_client = new Client($name, $category_id); $test_client->save(); $name2 = "Dicks"; $category_id2 = $test_stylist2->getId(); $test_client2 = new Client($name2, $category_id2); $test_client2->save(); //Act $test_stylist->delete(); //Assert $this->assertEquals([$test_client2], Client::getAll()); }
function test_delete() { //arrange $stylist_name = "Lisa"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $client_name = "Alfred"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id, $stylist_id); $test_client->save(); $client_name2 = "Ludacris"; $stylist_id = $test_stylist->getId(); $test_client2 = new Client($client_name2, $id, $stylist_id); $test_client2->save(); $test_client->delete(); //assert $this->assertEquals([$test_client2], Client::getAll()); }
function testDeleteClientTasks() { //Arrange $stylist_name = "Allison"; $id = null; $test_stylist = new Stylist($stylist_name, $id); $test_stylist->save(); $client_name = "Paco"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id, $stylist_id); $test_client->save(); //Act $test_stylist->deleteOne(); //Assert $this->assertEquals([], Client::getAll()); }
function test_deleteAll() { //Arrange $name = "Stylist1"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "Client1"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $id, $stylist_id); $test_client->save(); $name = "Client2"; $test_client2 = new Client($name, $id, $stylist_id); $test_client2->save(); //Act Client::deleteAll(); $result = Client::getAll(); //Assert $this->assertEquals([], $result); }
function test_delete() { $name = "Jane Doe"; $test_stylist = new Stylist($name); $test_stylist->save(); $client_name = "Jimmy"; $client_stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $client_stylist_id); $test_client->save(); $client_name2 = "Coco"; $test_client2 = new Client($client_name2, $client_stylist_id); $test_client2->save(); $test_client->delete(); $result = Client::getAll(); $this->assertEquals([$test_client2], $result); }
function testDeleteAll() { //Arrange $stylist_name = "Gandalf the Gray"; $test_stylist = new Stylist($stylist_name, $id = null); $test_stylist->save(); $client_name = "Samwise"; $stylist_id = $test_stylist->getId(); $test_client = new Client($client_name, $id = null, $stylist_id); $test_client->save(); $client_name2 = "Arwen"; $test_client2 = new Client($client_name2, $id = null, $stylist_id); $test_client2->save(); //Act Client::deleteAll(); //Assert $result = Client::getAll(); $this->assertEquals([], $result); }
function test_deleteAll() { //Arrange $name = "Sasha"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name2 = "Sandra"; $test_stylist2 = new Stylist($name2, $id); $test_stylist2->save(); $c_name = "Garry Gergich"; $phone = "503-472-8959"; $stylist_id = $test_stylist->getId(); $test_client = new Client($c_name, $phone, $id, $stylist_id); $test_client->save(); $c_name2 = "Jerry Gergich"; $phone2 = "503-864-4444"; $stylist_id2 = $test_stylist2->getId(); $test_client2 = new Client($c_name2, $phone2, $id, $stylist_id2); $test_client2->save(); //Act Client::deleteAll(); //Assert $this->assertEquals([], Client::getAll()); }
protected function tearDown() { Stylist::deleteAll(); Client::getAll(); }
function testDelete() { $name = "Bob"; $phone = "555-555-5555"; $stylist_id = 1; $test_client = new Client($name, $phone, $stylist_id); $test_client->save(); $name2 = "Kevin"; $phone2 = "444-444-4444"; $test_client2 = new Client($name2, $phone2, $stylist_id); $test_client2->save(); $test_client->delete(); $this->assertEquals([$test_client2], Client::getAll()); }
$stylist->delete(); return $app['twig']->render('index.html.twig', array('stylists' => Stylist::getAll())); }); //allows the user to find a client's id $app->get("/clients/{id}", function ($id) use($app) { $client = Client::find($id); return $app['twig']->render('client.html.twig', array('client' => $client)); }); $app->get("/clients/{id}/edit", function ($id) use($app) { $client = Client::find($id); return $app['twig']->render('client.html.twig', array('client' => $client)); }); //Allows the user to update the client $app->patch("/clients/{id}", function ($id) use($app) { $client_name = $_POST['client_name']; $client = Client::find($id); $stylist = Stylist::find($id); $client->update($client_name); return $app['twig']->render('client.html.twig', array('client' => $client)); }); //Allows a user to delete a client //Getting error: Impossible to access attribute getStylistName //on null variable in stylist.html.twig at 8. $app->delete("/clients/{id}", function ($id) use($app) { $client = Client::find($id); $stylist = Stylist::find($client->getStylistId()); $client->delete(); $clients = Client::getAll(); return $app['twig']->render('stylist.html.twig', array('stylist' => $stylist, 'clients' => $clients)); }); return $app;
function test_delete() { //Arrange $name = "Erin"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $name = "George"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $stylist_id, $id); $test_client->save(); $name2 = "Judy"; $test_client2 = new Client($name2, $stylist_id, $id); $test_client2->save(); //Act $test_client2->delete(); //Assert $this->assertEquals([$test_client], Client::getAll()); }
function test_deleteAll() { $name = "Megan"; $id = null; $test_stylist = new Stylist($name, $id); $test_stylist->save(); $client_name = "Shawnee"; $stylist_id = $test_stylist->getId(); $test_client = new Client($id, $client_name, $stylist_id); $test_client->save(); $client_name2 = "Katie"; $stylist_id = $test_stylist->getId(); $test_client2 = new Client($id, $client_name, $stylist_id); $test_client2->save(); Client::deleteAll(); $result = Client::getAll(); $this->assertEquals([], $result); }
function test_delete() { $name = "Sally"; $phone = "555-555-5555"; $id = null; $test_stylist = new Stylist($name, $phone, $id); $test_stylist->save(); $name = "Maggie"; $phone = "123-321-1234"; $stylist_id = $test_stylist->getId(); $test_client = new Client($name, $phone, $id, $stylist_id); $test_client->save(); $name2 = "Steve"; $phone2 = "999-777-6666"; $stylist_id2 = $test_stylist->getId(); $test_client2 = new Client($name2, $phone2, $id, $stylist_id2); $test_client2->save(); $test_client->delete(); $this->assertEquals([$test_client2], Client::getAll()); }