/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $parishes = \montserrat\Contact::whereSubcontactType(CONTACT_TYPE_PARISH)->orderBy('organization_name', 'asc')->with('address_primary.state', 'diocese.contact_a')->get(); $parish_list[0] = 'N/A'; // 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->contact_a->organization_name; } $countries = \montserrat\Country::orderBy('iso_code')->pluck('iso_code', 'id'); $countries->prepend('N/A', 0); $ethnicities = \montserrat\Ethnicity::orderBy('ethnicity')->pluck('ethnicity', 'ethnicity'); $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); return view('contacts.create', compact('parish_list', 'ethnicities', 'states', 'countries', 'suffixes', 'prefixes', 'languages', 'genders', 'religions')); }
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) { // $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')); }