public static function createFromResponse(\SimpleXMLElement $response) { $venue = new Venue(); $venue->setId((int) $response->id); $venue->setName((string) $response->name); $location = array(); $location['city'] = (string) $response->location->city; $location['country'] = (string) $response->location->country; $location['street'] = (string) $response->location->street; $location['postalcode'] = (string) $response->location->postalcode; $venue->setLocation($location); $geoPoint = array(); $geoLocation = $response->location->children('geo', true); $geoPoint['lat'] = (string) $geoLocation->point->lat; $geoPoint['long'] = (string) $geoLocation->point->long; $venue->setGeoPoint($geoPoint); $venue->setUrl((string) $response->url); $venue->setWebsite((string) $response->website); $venue->setPhoneNumber((string) $response->phonenumber); $images = array(); foreach ($response->image as $image) { $imageAttributes = $image->attributes(); if (!empty($imageAttributes->size)) { $images[(string) $imageAttributes->size] = (string) $image; } } $venue->setImages($images); return $venue; }
private function getTestVenue() { $v = new Venue(); $v->setName(get_class($this) . ': ' . date('Y-m-d_H:i:s')); $v->setDescription('Auto-generated by SimpleTest'); $v->setPubState('Published'); return $v; }
public function testGh107HasManyThroughIncludeEager() { $venue = Venue::find(1, array('include' => array('events'))); $this->assertEquals(1, $venue->events[0]->id); $venue = Venue::find(1, array('include' => array('hosts'))); $this->assertEquals(1, $venue->hosts[0]->id); }
public function test_gh107_has_many_through_include_eager() { $venue = Venue::find(1, array('include' => array('events'))); $this->assert_equals(1, $venue->events[0]->id); $venue = Venue::find(1, array('include' => array('hosts'))); $this->assert_equals(1, $venue->hosts[0]->id); }
protected function saveModel($hospitality = false) { if (Input::get('id')) { $hospitality = Hospitality::find(Input::get('id')); } if (!$hospitality) { $hospitality = new Hospitality(); } //$contact = Contact::where('last_name', Input::get('contact'))->first(); if (Input::get('first_hotel_option')) { $hotel1 = Hotel::where('name', Input::get('first_hotel_option'))->first(); $hospitality->first_hotel_distance_from_airport = Input::get('first_hotel_distance_from_airport'); if ($hotel1) { $hospitality->first_hotel_option()->associate($hotel1); } } if (Input::get('second_hotel_option')) { $hotel2 = Hotel::where('name', Input::get('second_hotel_option'))->first(); $hospitality->second_hotel_distance_from_airport = Input::get('second_hotel_distance_from_airport'); if ($hotel2) { $hospitality->second_hotel_option()->associate($hotel2); } } if (Input::get('venue_id')) { $venue = Venue::find(Input::get('venue_id')); $hospitality->venue()->associate($venue); } $hospitality->save(); return $hospitality; }
public function loadModel($id) { $Model = Venue::model()->findByPk($id); if ($Model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $Model; }
function getVenueSummaries($pubStates = null) { global $logger; $logger->debug(get_class($this) . "::getVenues({$pubStates})"); $pubStates = $pubStates == null ? array('Published') : $pubStates; $db =& JFactory::getDBO(); // get the featured programs $query = 'SELECT DISTINCT v.eoid as oid, v.name as name, ev.value as pubState' . ' FROM _ez_relation_ as r, Venue as v, EnumeratedValue as ev' . ' WHERE (r.class_a = "Venue" AND r.class_b = "PublicationState")' . ' AND oid_b = ev.eoid AND ('; $sep = ""; foreach ($pubStates as $pubState) { $query .= $sep . 'ev.value="' . $pubState . '"'; $sep = ' OR '; } $query .= ")"; $db->setQuery($query); $venues = $db->loadAssocList(); $result = array(); foreach ($venues as $row) { $venue = new Venue($row); // Get the address $query = 'SELECT a.* FROM Address as a, _ez_relation_ as r' . ' WHERE (r.class_a = "Venue" AND r.class_b = "Address")' . ' AND a.eoid = r.oid_b AND r.oid_a = ' . $venue->getOid(); $db->setQuery($query); $addrs = $db->loadAssocList(); $addr = $addrs[0]; $venue->setAddress(new Address($addr)); // Get the event counts $types = array("Exhibition", "Program", "Course"); $venueEvents = array(); foreach ($types as $type) { $query = 'SELECT DISTINCT e.eoid ' . ' FROM ' . $type . ' as e, _ez_relation_ as r ' . ' WHERE r.class_a = "' . $type . '" AND r.class_b = "Venue" ' . ' AND r.oid_b = ' . $venue->getOid(); $db->setQuery($query); $events = $db->loadAssocList(); foreach ($events as $event) { $venueEvents[] = new $type($event); } } $venue->setEvents($venueEvents); $result[] = $venue; } return $result; }
public function getAllContent() { $SQL = "SELECT `Img_loc`, `Date`, `Venue`, `Desc` FROM `content`"; $this->connect(); $result = $this->conn->query($SQL); if ($result->num_rows > 0) { $array = array(); $i = 0; while ($row = $result->fetch_assoc()) { $v = new Venue(); $v->setImg($row["Img_loc"]); $v->setDate($row["Date"]); $v->setVenue($row["Venue"]); $v->setDesc($row["Desc"]); $array[$i] = $v; $i++; } return $array; } return NULL; }
public function test_to_json_include_nested_with_nested_options() { $venue = Venue::find(1); $json = $venue->to_json(array('include' => array('events' => array('except' => 'title', 'include' => array('host' => array('only' => 'id')))))); $decoded = (array) json_decode($json); $event = $decoded['events'][0]; $host = $event->host; $this->assert_equals(1, $decoded['id']); $this->assert_not_null($host->id); $this->assert_null(@$event->host->name); $this->assert_null(@$event->title); }
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"))); } }
protected function saveModel($company = false) { if (Input::get('id')) { $company = Company::find(Input::get('id')); } if (!$company) { $company = new Company(); } $company->name = Input::get('name'); $company->type = Input::get('type'); $company->references = Input::get('references'); $company->bank_details = Input::get('bank_details'); $company->tax_number = Input::get('tax_number'); $company->notes = Input::get('notes'); $address = $company->address()->first() ?: new Address(); $country = Country::where('id', 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(); $company->address()->associate($address); $company->save(); if (Input::get('venue_id')) { $company->venues()->detach(Venue::find(Input::get('venue_id'))); $company->venues()->attach(Venue::find(Input::get('venue_id'))); } if (Input::get('contact_id')) { $company->contacts()->detach(Contact::find(Input::get('contact_id'))); $company->contacts()->attach(Contact::find(Input::get('contact_id'))); } if (Input::get('event_id')) { $company->events()->detach(Events::find(Input::get('event_id'))); $company->events()->attach(Events::find(Input::get('event_id'))); } return $company; }
/** * A temporary method of generating test data. Will be * refactored out once all services have been implemented. * @param bean the EventSUmmaryPage bean * @return bean the EventSUmmaryPage bean w/ stubbed data */ private function loadDemoSummaryData($model) { global $logger; $logger->debug(get_class($this) . '::loadTestSummaryData()'); // Test Venues require_once WEB_INF . '/beans/Venue.php'; $v1 = new Venue(); $v1->setName('Hurd Gallery'); $v1->setOid(48); $v2 = new Venue(); $v2->setName('Taube Courtyard'); $v2->setOid(24); $v3 = new venue(); $v3->setName('Main Lobby'); $v3->setOid(17); $venues = array($v1, $v2, $v3); // Test Audience require_once WEB_INF . '/beans/Audience.php'; $a1 = new Audience(); $a1->setName('All Age Groups'); $a2 = new Audience(); $a2->setName('Adults'); $a3 = new Audience(); $a3->setName('Toddlers'); $audiences = array($a1, $a2, $a3); $list = $model->getList(); foreach ($list as $event) { $event->setFamily($this->randomizeTestBoolean()); $event->setAudience($this->randomizeTestArray($audiences, 1, 1)); } $model->setEvents($list); // Page Announcement $msg = "<strong>This is some introductory text about this section of " . "the web site if needed.</strong> Otherwise this would not be " . "here and everything below would move up so that there isn't a " . "big blank space."; $model->setAnnouncement($msg); return $model; }
public function test_count_by() { $this->assert_equals(2, Venue::count_by_state('VA')); $this->assert_equals(3, Venue::count_by_state_or_name('VA', 'Warner Theatre')); $this->assert_equals(0, Venue::count_by_state_and_name('VA', 'zzzzzzzzzzzzz')); }
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()); }
/** * Populates the Venue object from the request * @return bean Venue */ protected function getBeanFromRequest() { global $logger; $prgm = new Program($_REQUEST); $genre = new Genre(); $genre->setOid($_REQUEST['primaryGenre']); $prgm->setPrimaryGenre($genre); if (isset($_REQUEST['defaultVenue'])) { $venue = new Venue(); $venue->setOid($_REQUEST['defaultVenue']); $prgm->setDefaultVenue($venue); $prgm->setVenues(array($venue)); } // categories $cats = array(); if (isset($_REQUEST['audience'])) { foreach ($_REQUEST['audience'] as $oid) { $category = new Audience(); $category->setOid($oid); $cats['audience'][] = $category; } } if (isset($_REQUEST['genre'])) { foreach ($_REQUEST['genre'] as $oid) { $category = new Genre(); $category->setOid($oid); $cats['genre'][] = $category; } } if (isset($_REQUEST['series'])) { foreach ($_REQUEST['series'] as $oid) { $category = new Series(); $category->setOid($oid); $cats['series'][] = $category; } } if (isset($cats['audience'])) { $logger->debug("Number of audience categories in the form: " . count($cats['audience'])); } if (isset($cats['genre'])) { $logger->debug("Number of genre categories in the form: " . count($cats['genre'])); } if (isset($cats['series'])) { $logger->debug("Number of series categories in the form: " . count($cats['series'])); } if (isset($cats['audience']) || isset($cats['genre']) || isset($cats['series'])) { $prgm->setCategories($cats); } // related events $events = array(); if (isset($_REQUEST['exhibition'])) { foreach ($_REQUEST['exhibition'] as $oid) { $exhibition = new Exhibition(); $exhibition->setOid($oid); $events[] = $exhibition; } } if (isset($events)) { $logger->debug("Number of related exhibitions in the form: " . count($events)); $prgm->setExhibitions($events); } $events = array(); if (isset($_REQUEST['course'])) { foreach ($_REQUEST['course'] as $oid) { $course = new Course(); $course->setOid($oid); $events[] = $course; } } if (isset($events)) { $logger->debug("Number of related courses in the form: " . count($events)); $prgm->setCourses($events); } $activities = array(); if (isset($_REQUEST['activityChanged']) && $_REQUEST['activityChanged']) { // parse delimited attributes as pipe-delimited '|' string $startTimes = explode('|', $_REQUEST['activityStartTime']); $endTimes = explode('|', $_REQUEST['activityEndTime']); $venues = explode('|', $_REQUEST['activityVenueList']); $status = explode('|', $_REQUEST['activityStatusList']); $tickets = explode('|', $_REQUEST['activityTicketList']); for ($index = 0; $index < count($venues); $index++) { $schedule = new Schedule(); $stint = strtotime($startTimes[$index]); $etint = strtotime($endTimes[$index]); $schedule->setStartTime($stint); $schedule->setEndTime($etint); $venue = new Venue(); $venue->setOid($venues[$index]); $activity = new Performance(); $activity->setSchedule($schedule); $activity->setVenue($venue); $activity->setActivityStatus($status[$index]); $activity->setTicketCode($tickets[$index]); $activities[] = $activity; } } if (isset($activities)) { $logger->debug("Number of related performances in the form: " . count($activities)); $prgm->setChildren($activities); } return $prgm; }
function add($postArray) { $db = new db(); include_class('venues'); $e = new Error(); $name = $db->sanitize_to_db($postArray['name']); $dt = $db->sanitize_to_db($postArray['date']); $date = date("Y-m-d", strtotime($dt)); if ($postArray['time']) { $time = $db->sanitize_to_db($postArray['time']); $time = "'" . date("H:i:s", strtotime($time)) . "'"; } else { $time = "null"; } if ($postArray['cost'] != "") { $cost = $db->sanitize_to_db($postArray['cost']); $cost = "'{$cost}'"; } else { $cost = "null"; } $is_all_ages = $postArray['is_all_ages'] == '1' ? 1 : 0; $other_bands = $db->sanitize_to_db($postArray['other_bands']); $notes = $db->sanitize_to_db($postArray['notes']); if (User::isAdmin()) { $uo = User::get($postArray['user_id']); if (db::isError($uo)) { $e->add($uo); } else { if (!$uo->isAdmin() && $uo->isBandMember()) { $e->add("Invalid user. User must be a band member or an administrator."); } } } else { $uo = User::getCurrent(); } if ($postArray['venue_id'] != '0') { $ve = Venue::get($postArray['venue_id']); } if (db::isError($ve)) { $e->add($ve); } if ($e->hasErrors()) { return $e; } $user_id = $uo->getID(); $venue_id = $db->sanitize_to_db($postArray['venue_id']); if (!$name) { $name = is_object($ve) && !db::isError($ve) ? $db->sanitize_to_db($ve->getName()) : "(untitled show)"; } $r = mysql_query("insert into Shows (name, venue_id, date, time, user_id, cost, is_all_ages, other_bands, notes, is_active) values ('{$name}', '{$venue_id}', '{$date}', {$time}, {$user_id}, {$cost}, {$is_all_ages}, '{$other_bands}', '{$notes}'," . DEFAULT_ACTIVE . ")"); if ($r) { return Show::get(mysql_insert_id()); } else { return Error::MySQL(); } }
public function index() { $datums = Venue::selectRaw('name AS value')->addSelect('id', 'address_id', 'name_of_hall', 'indoor_or_outdoor'); if (Input::get('q')) { $queryTokens = explode(' ', Input::get('q')); foreach ($queryTokens as $queryToken) { $datums = $datums->where(function ($query) use($queryToken) { $query->where('name', 'like', '%' . $queryToken . '%')->orWhere('name_of_hall', 'like', '%' . $queryToken . '%'); }); } } $datums = $datums->distinct()->take(50)->get(); foreach ($datums as $datum) { $datum->tokens = array_merge(explode(' ', $datum->value), [$datum->value]); $address = $datum->address()->first(); if ($address) { $datum->email = $address->email; $country = $address->country()->first(); $datum->country = $country->name; } } return Response::json($datums); }
public function test_eager_loading_clones_nested_related_objects() { $venues = Venue::find(array(1, 2, 6, 9), array('include' => array('events' => array('host')))); $unchanged_host = $venues[2]->events[0]->host; $changed_host = $venues[3]->events[0]->host; $changed_host->name = "changed"; $this->assert_equals($changed_host->id, $unchanged_host->id); $this->assert_not_equals($changed_host->name, $unchanged_host->name); $this->assert_not_equals(spl_object_hash($changed_host), spl_object_hash($unchanged_host)); }
public function getVenueResults() { $venue = array(); $venue['name'] = Input::get('name'); $venue['country'] = Input::get('country'); $venue['city'] = Input::get('city'); $venue['min_capacity'] = Input::get('min_capacity'); $venue['max_capacity'] = Input::get('max_capacity'); $venue['min_rig_capacity'] = Input::get('min_rig_capacity'); $venue_results = Venue::select('venues.*', 'c.name as country', 'a.city as city')->join('adresses as a', 'venues.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id'); if (empty(Input::get('name')) && empty(Input::get('country')) && empty(Input::get('city')) && empty(Input::get('min_capacity')) && empty(Input::get('max_capacity')) && empty(Input::get('min_rig_capacity'))) { $venue_results->orderBy('venues.id', 'DESC')->take(5); } else { if (!empty(Input::get('name'))) { $venue_results->where('venues.name', 'LIKE', '%' . $venue['name'] . '%'); } if (!empty(Input::get('min_capacity'))) { $venue_results->whereRaw('CAST(venues.capacity AS SIGNED) > ' . (int) $venue['min_capacity']); } if (!empty(Input::get('max_capacity'))) { $venue_results->whereRaw('CAST(venues.capacity AS SIGNED) < ' . (int) $venue['max_capacity']); } if (!empty(Input::get('min_rig_capacity'))) { $venue_results->whereRaw('CAST(venues.rigging_capacity AS SIGNED) > ' . (int) $venue['min_rig_capacity']); } if (!empty(Input::get('city'))) { $city_search_terms = explode(',', Input::get('city')); $city_where_str = ""; for ($city_ndx = 0; $city_ndx < count($city_search_terms); $city_ndx++) { if ($city_ndx !== 0) { $city_where_str .= " OR a.city LIKE '%" . $city_search_terms[$city_ndx] . "%' "; } else { $city_where_str .= " a.city LIKE '%" . $city_search_terms[$city_ndx] . "%' "; } } $venue_results->whereRaw("(" . $city_where_str . ")"); } if (!empty(Input::get('country'))) { $country_search_terms = explode(',', Input::get('country')); $country_where_str = ""; for ($country_ndx = 0; $country_ndx < count($country_search_terms); $country_ndx++) { if ($country_ndx !== 0) { $country_where_str .= " OR c.name LIKE '%" . $country_search_terms[$country_ndx] . "%' "; } else { $country_where_str .= " c.name LIKE '%" . $country_search_terms[$country_ndx] . "%' "; } } $venue_results->whereRaw("(" . $country_where_str . ")"); } } $venue_results = $venue_results->get(); $data = []; foreach ($venue_results as $curr_venue) { $curr_venue = (object) ['DT_RowId' => $curr_venue->id, 'name' => $curr_venue->name, 'capacity' => $curr_venue->capacity, 'rigging_capacity' => $curr_venue->rigging_capacity, 'country' => $curr_venue->country, 'city' => $curr_venue->city]; $curr_entry = (object) $curr_venue; $data[] = $curr_entry; } echo json_encode(['data' => $data]); }
public function testCountBy() { $this->assertEquals(2, Venue::countByState('VA')); $this->assertEquals(3, Venue::countByStateOrName('VA', 'Warner Theatre')); $this->assertEquals(0, Venue::countByStateAndName('VA', 'zzzzzzzzzzzzz')); }
| It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('registration/company', function () { return Response::JSON(['test' => Session::getToken()]); }); Route::get('/test', function () { $event_date = '2015-10-13'; $task = (object) ['deadline_days_gap' => -2]; $new_deadline = strtotime(-$task->deadline_days_gap . ' days', strtotime($event_date)); echo date('Y-m-d', $new_deadline); return; $hotel = Hotel::find(4); Debugbar::info($hotel); $venue = Venue::find(77); $hospitality = $venue->hospitality; Debugbar::info($hospitality); $first_hotel = $hospitality->first_hotel_option()->associate($hotel); $first_hotel = $hospitality->first_hotel_option()->get(); Debugbar::info($first_hotel); echo 'test'; }); Route::get('/table-view', function () { return View::make('test/table-view'); }); /** ------------------------------------------ * Route model binding * ------------------------------------------ */ Route::model('user', 'User');
public function testSaveAutoIncrementId() { $venue = new Venue(array('name' => 'Bob')); $venue->save(); $this->assertTrue($venue->id > 0); }
?> <tr> <td><?php print $row->and_choice ? 'and' : 'or'; ?> </td> <td> <?php print $row->bool_choice ? $Question->positiveLang : $Question->negativeLang; ?> <?php print $Question->question; switch ($Question->option_id) { case QueryQuestion::OPTION_VENUE: if (is_null($Venues)) { $Venues = Venue::model()->findAll(array('condition' => 'active = 1', 'index' => 'id')); } print ' ' . $Venues[$row->query_option]; break; case QueryQuestion::OPTION_ORGANISATION: if (is_null($Organisations)) { $Organisations = Organisation::model()->findAll(array('condition' => 'active = 1', 'index' => 'id')); } print ' ' . $Organisations[$row->query_option]->title; break; case QueryQuestion::OPTION_INVITE: if (is_null($InviteQueries)) { $InviteQueries = Query::model()->findAll(array('condition' => 'invite = 1', 'index' => 'id')); } print ' ' . $InviteQueries[$row->query_option]->name; break;
protected function saveModel($event = false) { if (Input::get('id')) { $event = Events::find(Input::get('id')); } if (!$event) { $event = new Events(); } $event->name = Input::get('name'); $event->proposed_opening_time = Input::get('proposed_opening_time'); $event->proposed_closing_time = Input::get('proposed_closing_time'); $event->proposed_local_sponsors = Input::get('proposed_local_sponsors'); $event->promotional_activities = Input::get('promotional_activities'); $event->eval_financial_score = Input::get('eval_financial_score'); $event->eval_financial_text = Input::get('eval_financial_text'); $event->eval_marketing_score = Input::get('eval_marketing_score'); $event->eval_marketing_text = Input::get('eval_marketing_text'); $event->eval_travel_score = Input::get('eval_travel_score'); $event->eval_travel_text = Input::get('eval_travel_text'); $event->eval_production_score = Input::get('eval_production_score'); $event->eval_production_text = Input::get('eval_production_text'); $event->eval_extra_text = Input::get('eval_extra_text'); // new stuff 1 $event->curfew = Input::get('curfew'); $event->minimal_age_limit = Input::get('minimal_age_limit'); $event->alcohol_license = Input::get('alcohol_license'); $event->restrictions_on_merchandise_sales = Input::get('restrictions_on_merchandise_sales'); $event->sound_restrictions = Input::get('sound_restrictions'); $event->booked_for_setup_from = Input::get('booked_for_setup_from'); $event->booked_for_break_until = Input::get('booked_for_break_until'); // new stuff 2 $event->hotel1_name = Input::get('hotel1_name'); $event->hotel2_name = Input::get('hotel2_name'); $event->hotel1_website = Input::get('hotel1_website'); $event->hotel2_website = Input::get('hotel2_website'); $event->hotel1_travel_time_from_airport = Input::get('hotel1_travel_time_from_airport'); $event->hotel2_travel_time_from_airport = Input::get('hotel2_travel_time_from_airport'); $event->hotel1_travel_time_from_venue = Input::get('hotel1_travel_time_from_venue'); $event->hotel2_travel_time_from_venue = Input::get('hotel2_travel_time_from_venue'); $event->ticketsystem_enabled = Input::get('ticketsystem_enabled'); $event->currency_id = Input::get('currency_id'); $event->ticketsystem_recording_startdate = Input::get('ticketsystem_recording_startdate'); $event->ticketsystem_locked_for_promoter = Input::get('ticketsystem_locked_for_promoter'); $event->ticketsystem_autoremind_user_id = Input::get('ticketsystem_autoremind_user_id'); $event->ticketsystem_autoremind = Input::get('ticketsystem_autoremind'); $event->save(); if (Input::get('event_date')) { //error_log('Event date '.json_encode(Input::get('event_date'))); $input_date = strtotime(Input::get('event_date')); $date = $event->date()->first(); if ($date) { // update current date $date->datetime_start = date("Y-m-d H:i:s", $input_date); $date->datetime_end = date("Y-m-d H:i:s", $input_date); $date->update(); } else { // create new date $event_date = new Dates(['datetime_start' => date("Y-m-d H:i:s", $input_date), 'datetime_end' => date("Y-m-d H:i:s", $input_date)]); $event_date->save(); $event->date()->attach($event_date); } $response = Event::fire('event.datechanged', array($event)); } if (Input::get('contact_id')) { $event->contacts()->detach(Contact::find(Input::get('contact_id'))); $event->contacts()->attach(Contact::find(Input::get('contact_id'))); } if (Input::get('venue_id')) { $event->venues()->detach(Venue::find(Input::get('venue_id'))); $event->venues()->attach(Venue::find(Input::get('venue_id'))); } if (Input::get('company_id')) { $event->companies()->detach(Company::find(Input::get('company_id'))); $event->companies()->attach(Company::find(Input::get('company_id'))); } if (Input::get('promoter_id')) { $event->users()->detach(User::find(Input::get('promoter_id'))); $event->users()->attach(User::find(Input::get('promoter_id'))); } return $event; }
public function test_save_auto_increment_id() { $venue = new Venue(array('name' => 'Bob')); $venue->save(); $this->assert_true($venue->id > 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 search() { if (Input::All()) { $book_for = Input::get('book_for'); $book_location = Input::get('book_location'); $book_date = Input::get('book_date'); //match service in services table if this service exist// $services = Services::where('title', 'like', '%' . $book_for . '%')->orWhere('description', 'like', '%' . $book_for . '%')->get(); //match location from venue table who match this service with business id $business_ids = array(); foreach ($services as $key => $val) { $business_ids[] = $val->business_id; } $venueFind = Venue::where('city', 'like', '%' . $book_location . '%')->whereIn('business_id', $business_ids)->get(); $last_query = DB::getQueryLog(); // echo "<pre>";print_r($last_query);die; // return View::make('search.listing')->with('data',$services); $result = array(); foreach ($venueFind as $venue => $venueVal) { $userBookings = $venueVal->business->user_booking(); $last_query = DB::getQueryLog(); //echo "<pre>";print_r($last_query);die; if (isset($userBookings) && count($userBookings) > 0) { //compare date $date1 = date("m-d-Y", strtotime($userBookings->booking_date)); //echo $book_date.'<br>'; //echo $date1.'<br>';die; if (!strtotime($date1) == strtotime($book_date)) { $result[] = $venueVal->business; } } else { //show in listing // echo "<pre>";print_r($venueVal);die; $result[] = $venueVal->business; } } $data['city'] = Venue::get_unique_city(); $data['salon_listing'] = $result; $this->layout->nest('content', 'search.listing', $data); //echo "<pre>";print_r($services);die; //match in user booking table if this service already booked } else { return Redirect::to('/'); } }
<?php include 'base.php'; User::protect(); $section = 'venues'; include_class('venues'); include_class('band_members'); include_class('locations'); $ve = Venue::get($_GET['id']); if (!db::isError($ve)) { switch ($_GET['task']) { case 'update': $res = $ve->update($_POST); if (!db::isError($res)) { header('Location: venue_edit.php?id=' . $_GET['id']); } break; case 'deactivate': $res = $ve->deactivate(); if (!db::isError($res)) { header('Location: venue_edit.php?id=' . $_GET['id']); } break; case 'activate': $res = $ve->activate(); if (!db::isError($res)) { header('Location: venue_edit.php?id=' . $_GET['id']); } break; case 'delete': $res = $ve->remove();
public static function get_unique_city() { return Venue::distinct('city')->get(); }
public function test_get_real_attribute_name() { $venue = new Venue(); $this->assert_equals('name', $venue->get_real_attribute_name('name')); $this->assert_equals('name', $venue->get_real_attribute_name('marquee')); $this->assert_equals(null, $venue->get_real_attribute_name('invalid_field')); }