예제 #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;
 }