Exemple #1
0
 protected function saveModel($venue = false)
 {
     if (Input::get('id')) {
         $venue = Venue::find(Input::get('id'));
     }
     if (!$venue) {
         $venue = new Venue();
     }
     $venue->name = Input::get('name');
     $venue->indoor_or_outdoor = Input::get('indoor_or_outdoor');
     $venue->name_of_hall = Input::get('name_of_hall');
     $venue->capacity = Input::get('capacity');
     $venue->dimension_height = Input::get('dimension_height');
     $venue->dimension_width = Input::get('dimension_width');
     $venue->dimension_length = Input::get('dimension_length');
     $venue->rigging_capacity = Input::get('rigging_capacity');
     $venue->notes = Input::get('notes');
     $address = $venue->address()->first() ?: new Address();
     $country = Country::where('name', Input::get('country'))->first();
     $address->country()->associate($country);
     $address->address = Input::get('address_address');
     $address->postal_code = Input::get('address_postal_code');
     $address->city = Input::get('address_city');
     $address->state_province = Input::get('address_state_province');
     $address->phone = Input::get('address_phone');
     $address->fax = Input::get('address_fax');
     $address->email = Input::get('address_email');
     $address->website = Input::get('address_website');
     $address->save();
     $venue->address()->associate($address);
     $venue->save();
     $venue->save();
     if (Input::get('company_id')) {
         $venue->companies()->detach(Company::find(Input::get('company_id')));
         $venue->companies()->attach(Company::find(Input::get('company_id')));
     }
     if (Input::get('contact_id')) {
         $venue->contacts()->detach(Contact::find(Input::get('contact_id')));
         $venue->contacts()->attach(Contact::find(Input::get('contact_id')));
     }
     return $venue;
 }
Exemple #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $Venue = new Venue();
     if (isset($_POST['Venue'])) {
         $Venue->attributes = $_POST['Venue'];
         if ($Venue->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->breadcrumbs = array('Venues' => array('index'), 'Create Venue');
     $this->render('create', array('Venue' => $Venue));
 }
 public function addAction()
 {
     $params = $this->getRequest()->getParams();
     $coords = explode("/", $params['vn_coords']);
     $point = new stdClass();
     $point->lat = array_shift($coords);
     $point->lng = array_shift($coords);
     $venue = new Venue();
     $venue->group_id = NULL;
     $venue->name = $params['gid'] . "_" . $params['vn_name'];
     $venue->address = utf8_decode($params['vn_address']);
     $venue->coords = $this->_helper->json->encodeJson($point);
     $venue->description = $params['vn_description'];
     $venue->icon = $params['vn_icon'];
     try {
         $venue->save();
         $this->_helper->json->sendJson(array("msg" => Zend_Registry::get('Zend_Translate')->_("Venue added!")));
     } catch (Exception $e) {
         Util_Log::get()->DataAccess()->err("Doctrine Save Error: " . $e->getMessage());
         $this->_helper->json->sendJson(array("msg" => Zend_Registry::get('Zend_Translate')->_("Error adding Venue")));
     }
 }
 public function test_save_auto_increment_id()
 {
     $venue = new Venue(array('name' => 'Bob'));
     $venue->save();
     $this->assert_true($venue->id > 0);
 }
 function test_deleteVenue()
 {
     //Arrange
     $type = "Thai";
     $id = null;
     $test_cuisine = new Cuisine($type, $id);
     $test_cuisine->save();
     $test_cuisine_id = $test_cuisine->getId();
     $name = "Mai Thai";
     $address = "1139 NW Elm Street";
     $description = "Yum yum for my tum tum";
     $rating = 3;
     $name2 = "Screen Door";
     $address2 = "19849 SW Santee Court";
     $description2 = "Huge lines.  Not worth it.";
     $rating2 = 4;
     $test_venue = new Venue($name, $test_cuisine_id, $id, $rating, $address, $description);
     $test_venue2 = new Venue($name2, $test_cuisine_id, $id, $rating2, $address2, $description2);
     $test_venue->save();
     $test_venue2->save();
     //Act
     $test_venue->deleteVenue();
     //Assert
     $this->assertEquals([$test_venue2], Venue::getAll());
 }
Exemple #6
0
    Cuisine::deleteAll();
    return $app['twig']->render('index.html.twig', array('cuisines' => Cuisine::getAll(), 'cuisine_check' => false, 'venue_check' => false));
});
//Navigate to cuisine page
$app->get('/cuisines/{id}', function ($id) use($app) {
    $cuisine = Cuisine::find($id);
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues()));
});
//Create a new venue
$app->post('/venues', function () use($app) {
    $name = $_POST['name'];
    $cuisine_id = $_POST['cuisine_id'];
    $description = $_POST['description'];
    $address = $_POST['address'];
    $rating = $_POST['rating'];
    $venue = new Venue($name, $cuisine_id, $id = null, $rating, $address, $description);
    $venue->save();
    $cuisine = Cuisine::find($cuisine_id);
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues()));
});
// Delete a single venue from a cuisine
// $app->delete('/cuisine/{id}', function($id) use ($app) {
//     $venues = Venue::find($id);
//     foreach($venues as $venue) {
//         $venue
//     }
//     $venue->deleteVenue();
//     $cuisine = Cuisine::find($id);
//     return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'venues' => $cuisine->getVenues()));
// });
return $app;
 public function testSaveAutoIncrementId()
 {
     $venue = new Venue(array('name' => 'Bob'));
     $venue->save();
     $this->assertTrue($venue->id > 0);
 }
 public function test_before_save_returning_false_cancels_callbacks()
 {
     $this->assert_fires_returns_false(array('before_save', 'before_create'), 'before_save', function ($model) {
         $model = new Venue();
         $model->save();
     });
 }
 public function testBeforeSaveReturningFalseCancelsCallbacks()
 {
     $this->assertFiresReturnsFalse(array('beforeSave', 'beforeCreate'), 'beforeSave', function ($model) {
         $model = new Venue();
         $model->save();
     });
 }
 function test_deleteCuisineVenue()
 {
     //Arrange
     $type = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($type, $id);
     $test_cuisine->save();
     $name = "Montage";
     $cuisine_id = $test_cuisine->getId();
     $rating = 4;
     $address = "1139 NW Elm Street";
     $description = "Yum yum for my tum tum";
     $test_venue = new Venue($name, $cuisine_id, $id, $rating, $address, $description);
     $test_venue->save();
     //Act
     $test_cuisine->deleteCuisine();
     //Assert
     $this->assertEquals([], Venue::getAll());
 }