/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $vendor = \montserrat\Contact::with('addresses.state', 'addresses.location', 'phones.location', 'emails.location', 'websites', 'notes', 'touchpoints')->findOrFail($id); $files = \montserrat\Attachment::whereEntity('contact')->whereEntityId($vendor->id)->whereFileTypeId(FILE_TYPE_CONTACT_ATTACHMENT)->get(); $relationship_types = array(); $relationship_types["Primary Contact"] = "Primary Contact"; return view('vendors.show', compact('vendor', 'relationship_types', 'files')); // }
public function delete_attachment($file_name, $entity = 'event', $entity_id = 0, $type = NULL) { $path = $entity . '/' . $entity_id . '/'; switch ($type) { case 'group_photo': $file_name = 'group_photo.jpg'; $attachment = \montserrat\Attachment::whereEntity($entity)->whereEntityId($entity_id)->whereUri($file_name)->whereFileTypeId(FILE_TYPE_EVENT_GROUP_PHOTO)->firstOrFail(); $path = $entity . '/' . $entity_id . '/'; $updated_file_name = 'group_photo-deleted-' . time() . '.jpg'; break; case 'contract': $file_name = 'contract.pdf'; $attachment = \montserrat\Attachment::whereEntity($entity)->whereEntityId($entity_id)->whereUri($file_name)->whereFileTypeId(FILE_TYPE_EVENT_CONTRACT_PHOTO)->firstOrFail(); $path = $entity . '/' . $entity_id . '/'; $updated_file_name = 'contract-deleted-' . time() . '.pdf'; break; case 'schedule': $file_name = 'schedule.pdf'; $attachment = \montserrat\Attachment::whereEntity($entity)->whereEntityId($entity_id)->whereUri($file_name)->whereFileTypeId(FILE_TYPE_EVENT_CONTRACT)->firstOrFail(); $path = $entity . '/' . $entity_id . '/'; $updated_file_name = 'schedule-deleted-' . time() . '.pdf'; break; case 'evaluations': $file_name = 'evaluations.pdf'; $attachment = \montserrat\Attachment::whereEntity($entity)->whereEntityId($entity_id)->whereUri($file_name)->whereFileTypeId(FILE_TYPE_EVENT_EVALUATION)->firstOrFail(); $path = $entity . '/' . $entity_id . '/'; $updated_file_name = 'evaluations-deleted-' . time() . '.pdf'; break; case 'attachment': $attachment = \montserrat\Attachment::whereEntity($entity)->whereEntityId($entity_id)->whereUri($file_name)->whereFileTypeId(FILE_TYPE_CONTACT_ATTACHMENT)->firstOrFail(); $path = $entity . '/' . $entity_id . '/attachments/'; $file_extension = File::extension($path . $file_name); $file_basename = File::name($path . $file_name); $updated_file_name = $file_basename . '-deleted-' . time() . '.' . $file_extension; break; case 'avatar': $attachment = \montserrat\Attachment::whereEntity($entity)->whereEntityId($entity_id)->whereUri($file_name)->whereFileTypeId(FILE_TYPE_CONTACT_AVATAR)->firstOrFail(); $path = $entity . '/' . $entity_id . '/'; $updated_file_name = 'avatar-deleted-' . time() . '.png'; break; default: break; } if (!File::exists(storage_path() . '/app/' . $path . $file_name)) { abort(404); } if (Storage::move($path . $file_name, $path . $updated_file_name)) { $attachment->uri = $updated_file_name; $attachment->save(); $attachment->delete(); } return Redirect::action('RetreatsController@show', $entity_id); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $person = \montserrat\Contact::with('addresses.country', 'addresses.location', 'addresses.state', 'emails.location', 'emergency_contact', 'ethnicity', 'languages', 'notes', 'occupation', 'parish.contact_a.address_primary', 'parish.contact_a.diocese.contact_a', 'phones.location', 'prefix', 'suffix', 'religion', 'touchpoints.staff', 'websites', 'groups.group', 'a_relationships.relationship_type', 'a_relationships.contact_b', 'b_relationships.relationship_type', 'b_relationships.contact_a', 'event_registrations')->findOrFail($id); $files = \montserrat\Attachment::whereEntity('contact')->whereEntityId($person->id)->whereFileTypeId(FILE_TYPE_CONTACT_ATTACHMENT)->get(); $relationship_types = array(); $relationship_types["Child"] = "Child"; $relationship_types["Employee"] = "Employee"; $relationship_types["Husband"] = "Husband"; $relationship_types["Parent"] = "Parent"; $relationship_types["Parishioner"] = "Parishioner"; $relationship_types["Sibling"] = "Sibling"; $relationship_types["Wife"] = "Wife"; //dd($files); //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; } } } //not pretty but moves some of the processing to the controller rather than the blade $person->parish_id = ''; $person->parish_name = ''; if (!empty($person->parish)) { $person->parish_id = $person->parish->contact_id_a; $person->parish_name = $person->parish->contact_a->organization_name . ' (' . $person->parish->contact_a->address_primary->city . ') - ' . $person->parish->contact_a->diocese->contact_a->organization_name; } $preferred_language = \montserrat\Language::whereName($person->preferred_language)->first(); if (!empty($preferred_language)) { $person->preferred_language_label = $preferred_language->label; } else { $person->preferred_language_label = 'N/A'; } //dd($person->a_relationships); return view('persons.show', compact('person', 'files', 'relationship_types')); // }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $organization = \montserrat\Diocese::with('bishop')->findOrFail($id); $organization = \montserrat\Contact::with('addresses.state', 'addresses.location', 'phones.location', 'emails.location', 'websites', 'notes', 'phone_main_phone.location', 'a_relationships.relationship_type', 'a_relationships.contact_b', 'b_relationships.relationship_type', 'b_relationships.contact_a', 'event_registrations')->findOrFail($id); $files = \montserrat\Attachment::whereEntity('contact')->whereEntityId($organization->id)->whereFileTypeId(FILE_TYPE_CONTACT_ATTACHMENT)->get(); $relationship_types = array(); $relationship_types["Employer"] = "Employer"; $relationship_types["Primary Contact"] = "Primary Contact"; return view('organizations.show', compact('organization', 'files', 'relationship_types')); // }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $parish = \montserrat\Contact::with('pastor.contact_b', 'diocese.contact_a', 'addresses.state', 'addresses.location', 'phones.location', 'emails.location', 'websites', 'notes', 'parishioners.contact_b.address_primary.state', 'parishioners.contact_b.emails.location', 'parishioners.contact_b.phones.location', 'touchpoints', 'a_relationships.relationship_type', 'a_relationships.contact_b', 'b_relationships.relationship_type', 'b_relationships.contact_a', 'event_registrations')->findOrFail($id); $files = \montserrat\Attachment::whereEntity('contact')->whereEntityId($parish->id)->whereFileTypeId(FILE_TYPE_CONTACT_ATTACHMENT)->get(); $relationship_types = array(); $relationship_types["Primary Contact"] = "Primary Contact"; return view('parishes.show', compact('parish', 'files', 'relationship_types')); // }