Esempio n. 1
0
 public function storeCustomRecord($parameters)
 {
     $customer = Customer::create(['lang_id_301' => $this->request->has('lang') ? $this->request->input('lang') : null, 'group_id_301' => $this->request->input('group'), 'date_301' => $this->request->has('date') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('date'))->getTimestamp() : null, 'company_301' => $this->request->has('company') ? $this->request->input('company') : null, 'tin_301' => $this->request->has('tin') ? $this->request->input('tin') : null, 'gender_id_301' => $this->request->has('gender') ? $this->request->input('gender') : null, 'treatment_id_301' => $this->request->has('treatment') ? $this->request->input('treatment') : null, 'state_id_301' => $this->request->has('state') ? $this->request->input('state') : null, 'name_301' => $this->request->has('name') ? $this->request->input('name') : null, 'surname_301' => $this->request->has('surname') ? $this->request->input('surname') : null, 'avatar_301' => $this->request->has('avatar') ? $this->request->input('avatar') : null, 'birth_date_301' => $this->request->has('birthDate') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $this->request->input('birthDate'))->getTimestamp() : null, 'email_301' => $this->request->input('email'), 'phone_301' => $this->request->has('phone') ? $this->request->input('phone') : null, 'mobile_301' => $this->request->has('mobile') ? $this->request->input('mobile') : null, 'user_301' => $this->request->input('user'), 'password_301' => Hash::make($this->request->input('password')), 'active_301' => $this->request->has('active'), 'confirmed_301' => false, 'country_id_301' => $this->request->has('country') ? $this->request->input('country') : null, 'territorial_area_1_id_301' => $this->request->has('territorialArea1') ? $this->request->input('territorialArea1') : null, 'territorial_area_2_id_301' => $this->request->has('territorialArea2') ? $this->request->input('territorialArea2') : null, 'territorial_area_3_id_301' => $this->request->has('territorialArea3') ? $this->request->input('territorialArea3') : null, 'cp_301' => $this->request->has('cp') ? $this->request->input('cp') : null, 'locality_301' => $this->request->has('locality') ? $this->request->input('locality') : null, 'address_301' => $this->request->has('address') ? $this->request->input('address') : null, 'latitude_301' => $this->request->has('latitude') ? $this->request->input('latitude') : null, 'longitude_301' => $this->request->has('longitude') ? $this->request->input('longitude') : null]);
     // set attachments
     $attachments = json_decode($this->request->input('attachments'));
     AttachmentLibrary::storeAttachments($attachments, 'crm', 'crm-customer', $customer->id_301, base_lang()->id_001);
 }
Esempio n. 2
0
 /**
  * Function to create a customer
  *
  * Input names to create customer
  *
  * lang_id_301 [langId]
  * group_id_301 [groupId]
  * date_301 [date]
  * company_301 [company]
  * tin_301 [tin]
  * gender_id_301 [gender]
  * treatment_id_301 [treatment]
  * state_id_301 [stateId]
  * name_301 [name]
  * surname_301 [surname]
  * avatar_301 [avatar]
  * birth_date_301 [birthDate]
  * email_301 [email]
  * phone_301 [phone]
  * mobile_301 [mobile]
  * user_301 [user]
  * password_301 [password]
  * active_301 [active]
  * country_id_301 [country]
  * territorial_area_1_id_301 [territorialArea1]
  * territorial_area_2_id_301 [territorialArea2]
  * cp_301 [cp]
  * locality_301 [locality]
  * address_301 [address]
  * latitude_301 [latitude]
  * longitude_301 [longitude]
  *
  * @param   \Illuminate\Http\Request        $request
  * @return  \Syscover\Crm\Models\Customer   $customer
  * @throws  \Exception
  */
 public static function createCustomer(Request $request)
 {
     if (!$request->has('email')) {
         throw new \Exception('You have to define an email field to record a user');
     }
     $customer = Customer::create(['lang_id_301' => $request->has('langId') ? $request->input('langId') : null, 'group_id_301' => $request->input('groupId'), 'date_301' => $request->has('date') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $request->input('date'))->getTimestamp() : date('U'), 'company_301' => $request->has('company') ? $request->input('company') : null, 'tin_301' => $request->has('tin') ? $request->input('tin') : null, 'gender_id_301' => $request->has('gender') ? $request->input('gender') : null, 'treatment_id_301' => $request->has('treatment') ? $request->input('treatment') : null, 'state_id_301' => $request->has('stateId') ? $request->input('stateId') : null, 'name_301' => $request->has('name') ? ucwords(strtolower($request->input('name'))) : null, 'surname_301' => $request->has('surname') ? ucwords(strtolower($request->input('surname'))) : null, 'avatar_301' => $request->has('avatar') ? $request->input('avatar') : null, 'birth_date_301' => $request->has('birthDate') ? \DateTime::createFromFormat(config('pulsar.datePattern'), $request->input('birthDate'))->getTimestamp() : null, 'email_301' => strtolower($request->input('email')), 'phone_301' => $request->has('phone') ? $request->input('phone') : null, 'mobile_301' => $request->has('mobile') ? $request->input('mobile') : null, 'user_301' => $request->has('user') ? $request->input('user') : strtolower($request->input('email')), 'password_301' => $request->has('password') ? Hash::make($request->input('password')) : Hash::make(Miscellaneous::randomStr(8)), 'active_301' => $request->has('active'), 'confirmed_301' => false, 'country_id_301' => $request->has('country') ? $request->input('country') : null, 'territorial_area_1_id_301' => $request->has('territorialArea1') ? $request->input('territorialArea1') : null, 'territorial_area_2_id_301' => $request->has('territorialArea2') ? $request->input('territorialArea2') : null, 'territorial_area_3_id_301' => $request->has('territorialArea3') ? $request->input('territorialArea3') : null, 'cp_301' => $request->has('cp') ? $request->input('cp') : null, 'locality_301' => $request->has('locality') ? ucfirst($request->input('locality')) : null, 'address_301' => $request->has('address') ? $request->input('address') : null, 'latitude_301' => $request->has('latitude') ? $request->input('latitude') : null, 'longitude_301' => $request->has('longitude') ? $request->input('longitude') : null]);
     return $customer;
 }