Exemplo n.º 1
0
 /**
  * Update Contact attributes.
  *
  * @param Business $business
  * @param Contact  $contact
  * @param array    $data
  * @param string   $notes
  *
  * @return void
  */
 public function update(Business $business, Contact $contact, $data = [], $notes = null)
 {
     if (array_key_exists('birthdate', $data) && trim($data['birthdate']) != '') {
         $data['birthdate'] = Carbon::createFromFormat(trans('app.dateformat.carbon'), $data['birthdate']);
     }
     $contact->where('id', '=', $contact->id)->update($data);
     self::updateNotes($business, $contact, $notes);
 }
Exemplo n.º 2
0
 public function homepage()
 {
     $params = array('logo' => Title::findOrFail(1), 'timer' => Timer::findOrFail(1), 'about' => About::findOrFail(1), 'contacts' => Contact::where('enabled', '=', true)->orderBy('id', 'ASC')->get(), 'grouped' => GroupRepository::grouped(), 'offices' => Office::where('enabled', '=', true)->orderBy('position', 'ASC')->get(), 'title' => 'TWIGA – крупнейшая независимая коммуникационная группа в России и странах СНГ');
     /*if (Request::has('r')) {
     			$r = Request::get('r');
     			Session::set('r', $r);
     
     			return redirect('/#' . $r);
     		}*/
     $view = Agent::isTablet() || Request::has('t') ? 'tablet.homepage' : (Agent::isMobile() || Request::has('m') ? 'mobile.homepage' : 'index.homepage');
     return view($view, $params);
 }
Exemplo n.º 3
0
 /**
  * Get the needed authorization credentials from the request.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return array
  */
 protected function getCredentials(Request $request)
 {
     $credentials = $request->only('password');
     $credentials['id'] = null;
     $contactKey = session('contact_key');
     if ($contactKey) {
         $contact = Contact::where('contact_key', '=', $contactKey)->first();
         if ($contact && !$contact->is_deleted) {
             $credentials['id'] = $contact->id;
         }
     }
     return $credentials;
 }
Exemplo n.º 4
0
 public function search(Request $request)
 {
     $q = $request->input('search');
     if (preg_match("/^[0-9]+\$/", $q)) {
         $data = ['title' => 'Список контактов', 'view_all' => false, 'contacts' => Contact::get()->where('phone', $q)->toArray()];
         return view('templates.index', $data);
     } elseif (filter_var($q, FILTER_VALIDATE_EMAIL)) {
         $data = ['title' => 'Список контактов', 'view_all' => false, 'contacts' => Contact::where('email', $q)->get()->toArray()];
         return view('templates.index', $data);
     } else {
         $q = '%' . $q . '%';
         $data = ['title' => 'Список контактов', 'view_all' => false, 'contacts' => Contact::where('fullname', 'LIKE', $q)->get()->toArray()];
         //dd($data);
         return view('templates.index', $data);
     }
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $contactKey = session('contact_key');
     if (!$contactKey) {
         return false;
     }
     $contact = Contact::where('contact_key', '=', $contactKey)->with('client')->first();
     if (!$contact || $contact->is_deleted) {
         return false;
     }
     $client = $contact->client;
     $hasDocuments = DB::table('invoices')->where('invoices.client_id', '=', $client->id)->whereNull('invoices.deleted_at')->join('documents', 'documents.invoice_id', '=', 'invoices.id')->count();
     $view->with('hasQuotes', $client->quotes->count());
     $view->with('hasCredits', $client->creditsWithBalance->count());
     $view->with('hasDocuments', $hasDocuments);
 }
 /**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function reset(Request $request)
 {
     $this->validate($request, $this->getResetValidationRules());
     $credentials = $request->only('password', 'password_confirmation', 'token');
     $credentials['id'] = null;
     $contactKey = session('contact_key');
     if ($contactKey) {
         $contact = Contact::where('contact_key', '=', $contactKey)->first();
         if ($contact && !$contact->is_deleted) {
             $credentials['id'] = $contact->id;
         }
     }
     $broker = $this->getBroker();
     $response = Password::broker($broker)->reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return $this->getResetSuccessResponse($response);
         default:
             return $this->getResetFailureResponse($request, $response);
     }
 }
 private function getContact()
 {
     $contactKey = session('contact_key');
     if (!$contactKey) {
         return false;
     }
     $contact = Contact::where('contact_key', '=', $contactKey)->first();
     if (!$contact || $contact->is_deleted) {
         return false;
     }
     return $contact;
 }
Exemplo n.º 8
0
 /**
  * Link User to existing Contacts
  * 
  * @return boolean   The User was linked to at least one Contact
  */
 public function linkToContacts()
 {
     $contacts = Contact::where(['email' => $this->email])->whereNotNull('email')->whereNull('user_id')->get();
     if ($contacts->isEmpty()) {
         return false;
     }
     foreach ($contacts as $contact) {
         $contact->user()->associate($this)->save();
     }
     return true;
 }
 /**
  * Find an existing Contact By UserId.
  * 
  * @param int $userId
  *
  * @return Collection|Builder
  */
 protected function findExistingContactsByUserId($userId)
 {
     return Contact::where('user_id', '=', $userId)->get();
 }