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);
 }
 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);
 }
 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 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);
 }
 protected function get_relationship($type = null)
 {
     if (!$type) {
         $type = $this->relationship_name;
     }
     switch ($type) {
         case 'belongs_to':
             $ret = Event::find(5);
             break;
         case 'has_one':
             $ret = Employee::find(1);
             break;
         case 'has_many':
             $ret = Venue::find(2);
     }
     return $ret;
 }
Exemple #6
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 #7
0
 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;
 }
 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));
 }
 function test_find()
 {
     //Arrange
     $type = "Thai";
     $id = null;
     $rating = 4;
     $address = "1139 NW Elm Street";
     $description = "Yum yum for my tum tum";
     $test_Cuisine = new Cuisine($type, $id);
     $test_Cuisine->save();
     $name = "Mai Thai";
     $name2 = "Screen Door";
     $cuisine_id = $test_Cuisine->getId();
     $test_Venue = new Venue($name, $cuisine_id, $id, $rating, $address, $description);
     $test_Venue->save();
     $test_Venue2 = new Venue($name, $cuisine_id, $id, $rating, $address, $description);
     $test_Venue2->save();
     //Act
     $result = Venue::find($test_Venue->getId());
     //Assert
     $this->assertEquals($test_Venue, $result);
 }
 public function test_alias_attribute_setter()
 {
     $venue = Venue::find(1);
     $venue->marquee = 'new name';
     $this->assert_equals($venue->marquee, 'new name');
     $this->assert_equals($venue->marquee, $venue->name);
     $venue->name = 'another name';
     $this->assert_equals($venue->name, 'another name');
     $this->assert_equals($venue->marquee, $venue->name);
 }
 public function test_alias_attribute_custom_setter()
 {
     Venue::$use_custom_set_city_setter = true;
     $venue = Venue::find(1);
     $venue->mycity = 'cityname';
     $this->assert_equals($venue->mycity, 'cityname#');
     $this->assert_equals($venue->mycity, $venue->city);
     $venue->city = 'anothercity';
     $this->assert_equals($venue->city, 'anothercity#');
     $this->assert_equals($venue->city, $venue->mycity);
     Venue::$use_custom_set_city_setter = false;
 }
Exemple #12
0
| 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');
Exemple #13
0
 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 testEagerLoadingClonesNestedRelatedObjects()
 {
     $venues = Venue::find(array(1, 2, 6, 9), array('include' => array('events' => array('host'))));
     $unchangedHost = $venues[2]->events[0]->host;
     $changedHost = $venues[3]->events[0]->host;
     $changedHost->name = "changed";
     $this->assertEquals($changedHost->id, $unchangedHost->id);
     $this->assertNotEquals($changedHost->name, $unchangedHost->name);
     $this->assertNotEquals(spl_object_hash($changedHost), spl_object_hash($unchangedHost));
 }