public function destroy(Request $request, $id) { $contact = Contact::find($id); $contact->delete(); $request->session()->flash('alert-success', 'Message has been deleted successfully !'); return redirect('/message')->withInput(); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Contact $contact) { // $user = User::find($contact->id); if (!$user->types()->where('user_types.id', 1)->first()) { $user->types()->attach([1]); } $contact = Contact::find($user->id); // return $contact; $schedules = $this->schedules->contact($contact); //Gets any Scheduled Responses for the contact grouped by Template // $template_ids = '0,'; $template_ids = []; $template_group_status = []; // dd($template_group_status); // $template_ids = rtrim($template_ids,','); if ($schedules) { foreach ($schedules as $s) { //If any response schedule is set to 'Paused' set a status for that templateid to paused. if ($s->status == 'paused') { !isset($template_group_status[$s->template->id]) ? $template_group_status[$s->template->id] = ['template_id' => $s->template->id, 'status' => 'paused'] : null; } $template_ids[] = $s->template->id; } $response_templates = \App\ResponseTemplate::whereIn('id', $template_ids)->get(); } // $schedules = new \App\ResponseSchedule; // $response_templates = new \App\ResponseTemplate; return view('contacts.show', ['title' => $contact->fullname, 'contact' => $contact, 'schedules' => $schedules, 'response_templates' => $response_templates, 'template_group_status' => $template_group_status]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $contact = Contact::find($id); if (is_null($contact)) { return response()->json(['error' => 'No contact found with ID ' . $id], 404); } $contact->delete(); return $contact; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $contact = Contact::find($id); if ($contact) { $id = $contact['id']; $name = $contact['name']; $contact->delete(); return redirect()->route('admin_contact')->with('message', 'تم حذف رسالة التواصل رقم ' . $id . ' باسم "' . $name . '" بنجاح!')->with('alert-class', 'alert-warning'); } }
/** * Run the database seeds. * * @return void */ public function run() { $user = User::find(1); $customer = Customer::find(1); $contact = Contact::find(1); $prod = Product::find(1); $iol_prod = Product::find(2); $briefing_owner = BriefingOwner::find(1); $briefing_source = BriefingSource::find(1); factory(App\Briefing::class)->create(['user_id' => $user->id, 'last_updated_user_id' => $user->id, 'customer_id' => $customer->id, 'customer_type_id' => $customer->customer_type_id, 'contact_id' => $contact->id, 'prod_id' => $prod->id, 'iol_prod_id' => $iol_prod->id, 'briefing_owner_id' => $briefing_owner->id, 'briefing_source_id' => $briefing_source->id]); }
/** * Handle the command. * * @param ContactCommand $command * @return void */ public function handle(ContactCommand $command) { $contact = Contact::find($command->id); $contact->title = $command->title; $contact->address = $command->address; $contact->city = $command->city; $contact->state = $command->state; $contact->zip = $command->zip; $contact->email = $command->email; $contact->phone = $command->phone; $contact->save(); }
public function update($id, $status) { if (empty($id)) { return redirect('/admin/contacts'); } $contacts = Contact::find($id); if (empty($contacts)) { return redirect('/admin/contacts'); } $contacts->status = $status; $contacts->save(); return redirect('/admin/contacts'); }
/** * Handle the event. * * @param ScheduleResponse $event * @return void */ public function handle(ScheduleResponse $event) { // // if(!$response_templates = ResponseTemplate::where('trigger_event',1)->orderBy('created_at','desc')->get()) // { // return false; // } $response_templates = ResponseTemplate::where('trigger_event', 1)->orderBy('created_at', 'desc')->get(); $contact = Contact::find($event->inquiry->user_id); foreach ($response_templates as $t) { $this->schedule->create($t, $contact); } \Mail::raw('Scheduled Responses were created for ' . $contact->fullname, function ($m) { $m->to('*****@*****.**', 'Tim Bradshaw')->from('*****@*****.**', 'LTD Sailing')->subject('The Prospect Inquiry Event Handler Fired to Create Scheduled Responses'); }); }
/** * When a trigger event fires, this method creates all response_schedule entries * @param ResponseTemplate $template Pass in a Response Template * @param Contact $contact Pass in a Contact Model * @return ResponseSchedule Returns a response schedule object for this Contact and Template. */ public function create(ResponseTemplate $template, Contact $contact) { //Create the Response Schedule events // return $template; !isset($contact->id) ? $contact = Contact::find(1) : ($contact = $contact); foreach ($template->details as $d) { $sched = new ResponseSchedule(); $sched->user_id = $contact->id; $sched->scheduled_date = Carbon::now()->addDays($d->number_of_days); $sched->response_template_detail_id = $d->id; $sched->most_recent_note_id = 0; $sched->save(); } $fullsched = ResponseSchedule::where('user_id', $contact->id)->whereHas('detail', function ($q) use($template) { $q->where('response_template_details.response_template_id', $template->id); })->get(); return $fullsched; }
public function changeContactInfo(Request $request) { if ($request->type == 'contact') { $item = Contact::find($request->entity); if ($request->name == 'first_name') { $item->first_name = $request->value; } elseif ($request->name == 'last_name') { $item->last_name = $request->value; } elseif ($request->name == 'email') { $item->email = $request->value; } elseif ($request->name == 'title') { $item->title = $request->value; } else { } $item->save(); } elseif ($request->type == 'address') { $item = Address::find($request->entity); $item->full_string = $request->value; $item->save(); return $request->all(); } elseif ($request->type == 'phone') { $item = Phone::find($request->entity); if ($request->name == 'type') { $item->type = $request->value; } elseif ($request->name == 'number') { $item->number = $request->value; } elseif ($request->name == 'from') { $item->available_from = $request->value; } elseif ($request->name == 'to') { $item->available_to = $request->value; } else { } $item->save(); return $request->all(); } else { } }
public function messages(Request $request) { // if ($request->action == 'create') { return view('admin.pages.contact.create'); } if ($request->action == 'edit' && isset($request->id)) { $contact = \App\Contact::find($request->id); return view('admin.pages.contact.edit', compact('contact')); } $request = json_encode($request->all()); $request = json_decode($request, true); $api_url = route('api.message.index', $request); return view('admin.pages.contact.listing', compact('api_url')); }
public function removeContact($campaign_id, $contact_id) { $campaign = Campaign::find($campaign_id); $contact = Contact::find($contact_id); $campaign->contacts()->detach($contact->id); return redirect()->back()->with('message', "{$contact->email} has been removed from the Campaign"); }
/** * returns Contact information */ public function getContact() { return response()->json(Contact::find(1)); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $contact = Contact::find($id); $contact->delete(); return response()->json($contact); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $contact = Contact::find($id); if ($contact != null) { $deleted = $contact->delete(); if ($deleted) { $returnValue['status'] = 200; $returnValue['message'] = "Contact was successfully deleted."; return Response::json($returnValue, 200); } $returnValue['status'] = 400; $returnValue['error_message'] = 'An error occurred while trying to delete the selected contact.'; return Response::json($returnValue, 400); } $returnValue['status'] = 404; $returnValue['error_message'] = 'Contact not found.'; return Response::json($returnValue, 404); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $contact = Contact::find($id); $contact->delete(); return json_encode(Contact::all()); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $contact = Contact::find($id); return view('contacts.show', compact('contact')); }
public function queueEmails($id) { $touch = Touch::find($id); $signups = array_column($touch->campaign->signups->toArray(), 'contact_id'); $contactIds = array_column($touch->campaign->contacts->toArray(), 'id'); $sentContactIds = Email::where('touch_id', $touch->id)->where('trackable', true)->groupBy('contact_id')->lists('contact_id')->toArray(); $unsentContactIds = array_diff($contactIds, $sentContactIds, $signups); $queuedEmails = 0; foreach ($unsentContactIds as $contact_id) { $contact = Contact::find($contact_id); if (!$contact->unsubscribe && !$contact->bounced) { $email = Email::create(['subject' => $touch->subject, 'reply_to' => $touch->campaign->client->reply_to, 'from' => $touch->campaign->client->reply_to, 'send_on' => $touch->send_on, 'template' => "emails.{$touch->template}", 'draft' => false, 'trackable' => true, 'campaign_id' => $touch->campaign->id, 'contact_id' => $contact->id, 'touch_id' => $touch->id]); $email->salted_id = bcrypt($email->id); $email->save(); $queuedEmails++; } } return redirect()->back()->with('message', "{$queuedEmails} emails queued"); }
/** * Remove the specified resource from storage. * * @param $id * @return \Illuminate\Http\JsonResponse */ public function destroy($id) { $contact = Contact::find($id); $contact->delete(); return response()->json(['status' => 'success'], 200); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request, Validator $validator) { $data = $request->all(); // dd($data); $data['technical_consult']['owner_id'] = $request->user()->id; $data['technical_consult']['color'] = (new Alfred())->randomColor(); $data['email_message']['date'] = empty($data['email_message']['date']) ? date('Y-m-d') : $data['email_message']['date']; $data['email_message']['time'] = empty($data['email_message']['time']) ? date('H:i') : $data['email_message']['time']; // CRIA CONSULTA TÉCNICA if (isset($data['technical_consult_id']) && $data['technical_consult_id'] > 0) { $technical_consult = TechnicalConsult::find($data['technical_consult_id']); } else { $technical_consult = TechnicalConsult::create($data['technical_consult']); } if (!$technical_consult) { $this->sys_notifications[] = array('type' => 'danger', 'message' => 'Erro ao criar consulta técnica'); $request->session()->flash('sys_notifications', $this->sys_notifications); return back()->withInput($request->all()); } $email_data = $data['email_message']; $email_data['date'] = date('Y-m-d H:i:s', strtotime($email_data['date'] . ' ' . $email_data['time'] . ':00')); $contact = Contact::find($data['technical_consult']['contact_id']); $email_data['to'] = $contact->email; $email_data['toname'] = $contact->name; $email_data['from'] = $request->user()->email; $email_data['subject'] = $data['technical_consult']['title']; $email_data['consulta_tecnica_id'] = $technical_consult->id; $email_data['owner_id'] = $request->user()->id; $email_data['body_html'] = $data['technical_consult']['description']; $email_data['body_text'] = strip_tags($data['technical_consult']['description']); $email_data['email_message_id'] = $data['email_message_id'] && !empty($data['email_message_id']) ? $data['email_message_id'] : null; // CRIA EMAIL MESSAGE $email_message = EmailMessage::create($email_data); if (!$email_message) { $this->sys_notifications[] = array('type' => 'danger', 'message' => $validator->errors()->first()); $request->session()->flash('sys_notifications', $this->sys_notifications); return back()->withInput($request->all()); } // ATTACH FILES $files = $request->file('file'); if ($files[0] != null) { $filesupload = (new FileEntryController())->upload($request, false, $email_message->id); if ($filesupload['uploaded'] > 0) { // $this->sys_notifications[] = array('type' => 'success', 'message' => $filesupload['uploaded'] . ' arquivos anexados'); } } $anexos = array(); if (!empty($filesupload['ids'])) { foreach ($filesupload['ids'] as $key => $fileid) { $entry = FileEntry::find($fileid); $entry->email_message_id = $email_message->id; $entry->save(); $anexos[] = $entry; } } // SEND MAIL if ($email_data['type'] == 1) { Mail::send('emails.message', ['email_data' => $email_data], function ($message) use($email_data, $anexos, $request, $email_message, $technical_consult) { foreach ($anexos as $anexo) { $message->attach(storage_path('app/' . $request->user()->id . '/' . $email_message->id . '/' . $anexo->original_filename)); } $message->from($email_data['from'], 'Consultas Técnicas'); $message->to($email_data['to'], $email_data['toname'])->subject('Consulta Técnica CT0' . $technical_consult->id); $message->bcc('*****@*****.**', $email_data['toname'])->subject('Consulta Técnica CT0' . $technical_consult->id); }); } $this->sys_notifications[] = array('type' => 'success', 'message' => 'Nova consulta técnica registrada com sucesso!'); $request->session()->flash('sys_notifications', $this->sys_notifications); return redirect('obras/'); return back()->withInput($request->all()); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $contact = Contact::find($id); $contact->delete($id); return redirect()->route('contact.index'); }
/** * Remove the specified contact from storage. * * @param int $id * @return Response */ public function destroy(Request $request, $client_id = null, $id) { $contact = Contact::find($id); if (!$contact) { $sys_notifications[] = array('type' => 'danger', 'message' => '<strong><i class="fa fa-warning"></i></strong> Contato não encontrado!'); $request->session()->flash('sys_notifications', $sys_notifications); return back()->withInput($request->all()); } if ($contact->destroy($id)) { $sys_notifications[] = array('type' => 'success', 'message' => '<strong><i class="fa fa-check"></i></strong> Contato excluído com sucesso!'); } else { $sys_notifications[] = array('type' => 'danger', 'message' => '<strong><i class="fa fa-warning"></i></strong> Não foi possível excluir o contato!'); } $request->session()->flash('sys_notifications', $sys_notifications); $data = $request->all(); $back_to = isset($data['back_to']) ? $data['back_to'] : '/contatos/' . $contato->id; return redirect($back_to)->withInput($request->all()); }
public function showContact_page() { $details_admin = Contact::find(1); $img = Contact_Image::find(1); return view('Admin_Pages.Admin_contact', compact('details_admin', 'img')); }
public function setContactIdAttribute($contactId) { $this->save(); $contact = Contact::find($contactId); $this->contacts()->attach($contact); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $contact = Contact::find($id); $contact->delete(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'object has been deleted'), 'id' => $id)); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $input = json_decode(\Request::input('contacts')); $contact = Contact::find($id); foreach ($input as $key => $value) { $contact[$key] = $value; } $contact->save(); return \Response::json(array('success' => true, 'contacts' => $contact)); }
Route::resource('api/contact', 'ContactsController'); Route::get('api/user', function () { $user = Auth::user(); return $user; }); Route::resource('api/file', 'FilesController'); //Upload Avatars Route::post('avatar/upload/{id}', function (Request $request, $id) { $contact = Contact::find($id); $fileName = date('U') . $contact->id . '.jpg'; $request->file('file')->move(public_path('assets/img/avatars'), $fileName); $contact->avatar = $fileName; $contact->save(); return $contact; }); //Upload Files Route::post('file/upload/{id}', function (Request $request, $id) { $file = new File(); $contact = Contact::find($id); $file->contact_id = $id; $folder = public_path('assets/files/' . $contact->name); if (is_dir($folder) == false) { mkdir($folder); } $uploadedFile = $request->file('file'); $fileName = $uploadedFile->getClientOriginalName(); $uploadedFile->move($folder, $fileName); $file->name = $fileName; $file->save(); return $file; });
public function update(Request $request, $id) { $contact = Contact::find($id); if (is_null($contact)) { return redirect()->back()->with('status', 'Missing Reference'); } $inquiry_id = $contact->inquiry_id; $chks = array('eie', 'dss'); foreach ($chks as $chk) { $contact->setAttribute($chk, Input::has($chk) ? true : false); } $contact->contactfname = $request->input('contactfname'); $contact->contactlname = $request->input('contactlname'); $contact->phone1 = $request->input('phone1'); $contact->phone1type = $request->input('phone1type'); $contact->phone2 = $request->input('phone2'); $contact->phone2type = $request->input('phone2type'); $contact->phone3 = $request->input('phone3'); $contact->phone3type = $request->input('phone3type'); $contact->reltoclient = $request->input('reltoclient'); $contact->refsrcreltoclient = $request->input('refsrcreltoclient'); $contact->address = $request->input('address'); $contact->city = $request->input('city'); $contact->usstate = $request->input('usstate'); $contact->zip = $request->input('zip'); $contact->isrefsrc = $request->input('isrefsrc'); $contact->isprimaryrefsrc = $request->input('isprimaryrefsrc'); $contact->isroisigned = $request->input('isroisigned'); $contact->save(); return redirect()->route('inquiryview', $inquiry_id); }
/** * Delete contact. * * @param $id * @param Request $request * @return Response */ public function delete($id, Request $request) { // Find contact by id // delete record // then redirect to listing page $contact = Contact::find($id); $contact->delete(); return redirect("contacts")->with('flash_message', 'Contact has been deleted successfully.'); }
public function detachContact(Request $request, $project_id, $contact_id) { $project = Project::find($project_id); $contact = Contact::find($contact_id); if (!$contact || !$project) { $this->sys_notifications[] = array('type' => 'warning', 'message' => 'Erro! Projeto ou Contato não encontrados.'); $request->session()->flash('sys_notifications', $this->sys_notifications); return back()->withInput($request->all()); } $project->contacts()->detach($contact_id); $this->sys_notifications[] = array('type' => 'success', 'message' => 'Contato <strong>' . $contact->name . '</strong> desvinculado do Projeto com sucesso!'); $request->session()->flash('sys_notifications', $this->sys_notifications); return redirect('/obras/' . $project_id . '#contatos'); }