/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['description' => 'required', 'name_a_b' => 'required', 'label_a_b' => 'required', 'name_b_a' => 'required', 'label_b_a' => 'required', 'contact_type_a' => 'required', 'contact_type_b' => 'required', 'is_active' => 'integer|min:0|max:1', 'is_reserved' => 'integer|min:0|max:1']);
     $relationship_type = new \montserrat\RelationshipType();
     $relationship_type->description = $request->input('description');
     $relationship_type->name_a_b = $request->input('name_a_b');
     $relationship_type->label_a_b = $request->input('label_a_b');
     $contact_type_a = \montserrat\ContactType::whereName($request->input('contact_type_a'))->firstOrFail();
     $contact_type_b = \montserrat\ContactType::whereName($request->input('contact_type_b'))->firstOrFail();
     if ($contact_type_a->is_reserved > 0) {
         // Explanation: primary type of Individual, Organization, or Household
         $relationship_type->contact_type_a = $contact_type_a->name;
     } else {
         // WARNING: assumes that if it is not a primary contact type then it is an organization (this may not always be true in the future, but for now ...
         $relationship_type->contact_type_a = 'Organization';
         $relationship_type->contact_sub_type_a = $contact_type_a->name;
     }
     if ($contact_type_b->is_reserved > 0) {
         // Explanation: primary type of Individual, Organization, or Household
         $relationship_type->contact_type_b = $contact_type_b->name;
     } else {
         // WARNING: assumes that if it is not a primary contact type then it is an organization (this may not always be true in the future, but for now ...
         $relationship_type->contact_type_b = 'Organization';
         $relationship_type->contact_sub_type_b = $contact_type_b->name;
     }
     $relationship_type->name_b_a = $request->input('name_b_a');
     $relationship_type->label_b_a = $request->input('label_b_a');
     $relationship_type->contact_type_b = $request->input('contact_type_b');
     $relationship_type->is_active = $request->input('is_active');
     $relationship_type->is_reserved = $request->input('is_reserved');
     $relationship_type->save();
     return Redirect::action('RelationshipTypesController@index');
     //
 }
예제 #2
0
 public function search()
 {
     $person = new \montserrat\Contact();
     $parishes = \montserrat\Contact::whereSubcontactType(CONTACT_TYPE_PARISH)->orderBy('organization_name', 'asc')->with('address_primary.state', 'diocese.contact_a')->get();
     $parish_list[0] = 'N/A';
     $contact_types = \montserrat\ContactType::whereIsReserved(TRUE)->pluck('label', 'id');
     $contact_types->prepend('N/A', 0);
     $subcontact_types = \montserrat\ContactType::whereIsReserved(FALSE)->whereIsActive(TRUE)->pluck('label', 'id');
     $subcontact_types->prepend('N/A', 0);
     // while probably not the most efficient way of doing this it gets me the result
     foreach ($parishes as $parish) {
         $parish_list[$parish->id] = $parish->organization_name . ' (' . $parish->address_primary_city . ') - ' . $parish->diocese_name;
     }
     $countries = \montserrat\Country::orderBy('iso_code')->pluck('iso_code', 'id');
     $countries->prepend('N/A', 0);
     $ethnicities = \montserrat\Ethnicity::orderBy('ethnicity')->pluck('ethnicity', 'id');
     $ethnicities->prepend('N/A', 0);
     $genders = \montserrat\Gender::orderBy('name')->pluck('name', 'id');
     $genders->prepend('N/A', 0);
     $languages = \montserrat\Language::orderBy('label')->whereIsActive(1)->pluck('label', 'id');
     $languages->prepend('N/A', 0);
     $prefixes = \montserrat\Prefix::orderBy('name')->pluck('name', 'id');
     $prefixes->prepend('N/A', 0);
     $religions = \montserrat\Religion::orderBy('name')->whereIsActive(1)->pluck('name', 'id');
     $religions->prepend('N/A', 0);
     $states = \montserrat\StateProvince::orderBy('name')->whereCountryId(1228)->pluck('name', 'id');
     $states->prepend('N/A', 0);
     $suffixes = \montserrat\Suffix::orderBy('name')->pluck('name', 'id');
     $suffixes->prepend('N/A', 0);
     $occupations = \montserrat\Ppd_occupation::orderBy('name')->pluck('name', 'id');
     $occupations->prepend('N/A', 0);
     //create defaults array for easier pre-populating of default values on edit/update blade
     // initialize defaults to avoid undefined index errors
     $defaults = array();
     $defaults['Home']['street_address'] = '';
     $defaults['Home']['supplemental_address_1'] = '';
     $defaults['Home']['city'] = '';
     $defaults['Home']['state_province_id'] = '';
     $defaults['Home']['postal_code'] = '';
     $defaults['Home']['country_id'] = '';
     $defaults['Home']['Phone'] = '';
     $defaults['Home']['Mobile'] = '';
     $defaults['Home']['Fax'] = '';
     $defaults['Home']['email'] = '';
     $defaults['Work']['street_address'] = '';
     $defaults['Work']['supplemental_address_1'] = '';
     $defaults['Work']['city'] = '';
     $defaults['Work']['state_province_id'] = '';
     $defaults['Work']['postal_code'] = '';
     $defaults['Work']['country_id'] = '';
     $defaults['Work']['Phone'] = '';
     $defaults['Work']['Mobile'] = '';
     $defaults['Work']['Fax'] = '';
     $defaults['Work']['email'] = '';
     $defaults['Other']['street_address'] = '';
     $defaults['Other']['supplemental_address_1'] = '';
     $defaults['Other']['city'] = '';
     $defaults['Other']['state_province_id'] = '';
     $defaults['Other']['postal_code'] = '';
     $defaults['Other']['country_id'] = '';
     $defaults['Other']['Phone'] = '';
     $defaults['Other']['Mobile'] = '';
     $defaults['Other']['Fax'] = '';
     $defaults['Other']['email'] = '';
     $defaults['Main']['url'] = '';
     $defaults['Work']['url'] = '';
     $defaults['Facebook']['url'] = '';
     $defaults['Google']['url'] = '';
     $defaults['Instagram']['url'] = '';
     $defaults['LinkedIn']['url'] = '';
     $defaults['Twitter']['url'] = '';
     foreach ($person->addresses as $address) {
         $defaults[$address->location->name]['street_address'] = $address->street_address;
         $defaults[$address->location->name]['supplemental_address_1'] = $address->supplemental_address_1;
         $defaults[$address->location->name]['city'] = $address->city;
         $defaults[$address->location->name]['state_province_id'] = $address->state_province_id;
         $defaults[$address->location->name]['postal_code'] = $address->postal_code;
         $defaults[$address->location->name]['country_id'] = $address->country_id;
     }
     foreach ($person->phones as $phone) {
         $defaults[$phone->location->name][$phone->phone_type] = $phone->phone;
     }
     foreach ($person->emails as $email) {
         $defaults[$email->location->name]['email'] = $email->email;
     }
     foreach ($person->websites as $website) {
         $defaults[$website->website_type]['url'] = $website->url;
     }
     //dd($person);
     return view('search.search', compact('prefixes', 'suffixes', 'person', 'parish_list', 'ethnicities', 'states', 'countries', 'genders', 'languages', 'defaults', 'religions', 'occupations', 'contact_types', 'subcontact_types'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     // TODO: make create and edit bishop id multi-select with all bishops defaulting to selected on edit
     // TODO: consider making one primary bishop with multi-select for seperate auxilary bishops (new relationship)
     $organization = \montserrat\Contact::with('address_primary.state', 'address_primary.location', 'phone_main_phone.location', 'phone_main_fax.location', 'email_primary.location', 'website_main', 'notes')->findOrFail($id);
     $states = \montserrat\StateProvince::orderby('name')->whereCountryId(COUNTRY_ID_USA)->pluck('name', 'id');
     $states->prepend('N/A', 0);
     $countries = \montserrat\Country::orderby('iso_code')->pluck('iso_code', 'id');
     $countries->prepend('N/A', 0);
     $defaults['state_province_id'] = STATE_PROVINCE_ID_TX;
     $defaults['country_id'] = COUNTRY_ID_USA;
     $defaults['Main']['url'] = '';
     $defaults['Work']['url'] = '';
     $defaults['Facebook']['url'] = '';
     $defaults['Google']['url'] = '';
     $defaults['Instagram']['url'] = '';
     $defaults['LinkedIn']['url'] = '';
     $defaults['Twitter']['url'] = '';
     foreach ($organization->websites as $website) {
         $defaults[$website->website_type]['url'] = $website->url;
     }
     $subcontact_types = \montserrat\ContactType::whereIsReserved(FALSE)->whereIsActive(TRUE)->pluck('label', 'id');
     $subcontact_types->prepend('N/A', 0);
     //dd($organization);
     return view('organizations.edit', compact('organization', 'states', 'countries', 'defaults', 'subcontact_types'));
 }
예제 #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     //
     $person = \montserrat\Contact::with('prefix', 'suffix', 'addresses.location', 'emails.location', 'phones.location', 'websites', 'parish', 'emergency_contact', 'notes')->findOrFail($id);
     //dd($person);
     $parishes = \montserrat\Contact::whereSubcontactType(CONTACT_TYPE_PARISH)->orderBy('organization_name', 'asc')->with('address_primary.state', 'diocese.contact_a')->get();
     $parish_list[0] = 'N/A';
     $contact_types = \montserrat\ContactType::whereIsReserved(TRUE)->pluck('label', 'id');
     $subcontact_types = \montserrat\ContactType::whereIsReserved(FALSE)->whereIsActive(TRUE)->pluck('label', 'id');
     $subcontact_types->prepend('N/A', 0);
     // while probably not the most efficient way of doing this it gets me the result
     foreach ($parishes as $parish) {
         $parish_list[$parish->id] = $parish->organization_name . ' (' . $parish->address_primary_city . ') - ' . $parish->diocese_name;
     }
     if (!empty($person->parish)) {
         $person->parish_id = $person->parish->contact_id_a;
     } else {
         $person->parish_id = 0;
     }
     $preferred_language = \montserrat\Language::whereName($person->preferred_language)->first();
     if (!empty($preferred_language)) {
         $person->preferred_language_id = $preferred_language->id;
     } else {
         $person->preferred_language_id = 0;
     }
     //again not at all elegant but this parses out the notes for easy display and use in the edit blade
     $person->note_health = '';
     $person->note_dietary = '';
     $person->note_contact = '';
     $person->note_room_preference = '';
     if (!empty($person->notes)) {
         foreach ($person->notes as $note) {
             if ($note->subject == "Health Note") {
                 $person->note_health = $note->note;
             }
             if ($note->subject == 'Dietary Note') {
                 $person->note_dietary = $note->note;
             }
             if ($note->subject == 'Contact Note') {
                 $person->note_contact = $note->note;
             }
             if ($note->subject == 'Room Preference') {
                 $person->note_room_preference = $note->note;
             }
         }
     }
     //dd($person);
     $countries = \montserrat\Country::orderBy('iso_code')->pluck('iso_code', 'id');
     $countries->prepend('N/A', 0);
     $ethnicities = \montserrat\Ethnicity::orderBy('ethnicity')->pluck('ethnicity', 'id');
     $ethnicities->prepend('N/A', 0);
     $genders = \montserrat\Gender::orderBy('name')->pluck('name', 'id');
     $genders->prepend('N/A', 0);
     $languages = \montserrat\Language::orderBy('label')->whereIsActive(1)->pluck('label', 'id');
     $languages->prepend('N/A', 0);
     $prefixes = \montserrat\Prefix::orderBy('name')->pluck('name', 'id');
     $prefixes->prepend('N/A', 0);
     $religions = \montserrat\Religion::orderBy('name')->whereIsActive(1)->pluck('name', 'id');
     $religions->prepend('N/A', 0);
     $states = \montserrat\StateProvince::orderBy('name')->whereCountryId(1228)->pluck('name', 'id');
     $states->prepend('N/A', 0);
     $suffixes = \montserrat\Suffix::orderBy('name')->pluck('name', 'id');
     $suffixes->prepend('N/A', 0);
     $occupations = \montserrat\Ppd_occupation::orderBy('name')->pluck('name', 'id');
     $occupations->prepend('N/A', 0);
     //create defaults array for easier pre-populating of default values on edit/update blade
     // initialize defaults to avoid undefined index errors
     $defaults = array();
     $defaults['Home']['street_address'] = '';
     $defaults['Home']['supplemental_address_1'] = '';
     $defaults['Home']['city'] = '';
     $defaults['Home']['state_province_id'] = '';
     $defaults['Home']['postal_code'] = '';
     $defaults['Home']['country_id'] = '';
     $defaults['Home']['Phone'] = '';
     $defaults['Home']['Mobile'] = '';
     $defaults['Home']['Fax'] = '';
     $defaults['Home']['email'] = '';
     $defaults['Work']['street_address'] = '';
     $defaults['Work']['supplemental_address_1'] = '';
     $defaults['Work']['city'] = '';
     $defaults['Work']['state_province_id'] = '';
     $defaults['Work']['postal_code'] = '';
     $defaults['Work']['country_id'] = '';
     $defaults['Work']['Phone'] = '';
     $defaults['Work']['Mobile'] = '';
     $defaults['Work']['Fax'] = '';
     $defaults['Work']['email'] = '';
     $defaults['Other']['street_address'] = '';
     $defaults['Other']['supplemental_address_1'] = '';
     $defaults['Other']['city'] = '';
     $defaults['Other']['state_province_id'] = '';
     $defaults['Other']['postal_code'] = '';
     $defaults['Other']['country_id'] = '';
     $defaults['Other']['Phone'] = '';
     $defaults['Other']['Mobile'] = '';
     $defaults['Other']['Fax'] = '';
     $defaults['Other']['email'] = '';
     $defaults['Main']['url'] = '';
     $defaults['Work']['url'] = '';
     $defaults['Facebook']['url'] = '';
     $defaults['Google']['url'] = '';
     $defaults['Instagram']['url'] = '';
     $defaults['LinkedIn']['url'] = '';
     $defaults['Twitter']['url'] = '';
     foreach ($person->addresses as $address) {
         $defaults[$address->location->name]['street_address'] = $address->street_address;
         $defaults[$address->location->name]['supplemental_address_1'] = $address->supplemental_address_1;
         $defaults[$address->location->name]['city'] = $address->city;
         $defaults[$address->location->name]['state_province_id'] = $address->state_province_id;
         $defaults[$address->location->name]['postal_code'] = $address->postal_code;
         $defaults[$address->location->name]['country_id'] = $address->country_id;
     }
     foreach ($person->phones as $phone) {
         $defaults[$phone->location->name][$phone->phone_type] = $phone->phone;
     }
     foreach ($person->emails as $email) {
         $defaults[$email->location->name]['email'] = $email->email;
     }
     foreach ($person->websites as $website) {
         $defaults[$website->website_type]['url'] = $website->url;
     }
     //dd($person);
     return view('persons.edit', compact('prefixes', 'suffixes', 'person', 'parish_list', 'ethnicities', 'states', 'countries', 'genders', 'languages', 'defaults', 'religions', 'occupations', 'contact_types', 'subcontact_types'));
 }