当前位置: 首页>>代码示例>>PHP>>正文


PHP Contact::createNew方法代码示例

本文整理汇总了PHP中Contact::createNew方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::createNew方法的具体用法?PHP Contact::createNew怎么用?PHP Contact::createNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::createNew方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param int $id
  * @return Response
  */
 public function update($publicId)
 {
     // return Response::json($contactos);
     $client = Client::scope($publicId)->firstOrFail();
     $client->setNit(trim(Input::get('nit')));
     $client->setName(trim(Input::get('name')));
     $client->setBussinesName(trim(Input::get('business_name')));
     $client->setWorkPhone(trim(Input::get('work_phone')));
     $client->setCustomValue1(trim(Input::get('l1')));
     $client->setCustomValue2(trim(Input::get('l2')));
     $client->setCustomValue3(trim(Input::get('l3')));
     $client->setCustomValue4(trim(Input::get('l4')));
     $client->setCustomValue5(trim(Input::get('l5')));
     $client->setCustomValue6(trim(Input::get('l6')));
     $client->setCustomValue7(trim(Input::get('l7')));
     $client->setCustomValue8(trim(Input::get('l8')));
     $client->setCustomValue9(trim(Input::get('l9')));
     $client->setCustomValue10(trim(Input::get('l10')));
     $client->setCustomValue11(trim(Input::get('l11')));
     $client->setCustomValue12(trim(Input::get('l12')));
     // $client->setCustomValue7(trim(Input::get('custom_value7')));
     // $client->setCustomValue8(trim(Input::get('custom_value8')));
     // $client->setCustomValue9(trim(Input::get('custom_value9')));
     // $client->setCustomValue10(trim(Input::get('custom_value10')));
     // $client->setCustomValue11(trim(Input::get('custom_value11')));
     // $client->setCustomValue12(trim(Input::get('custom_value12')));
     $client->setAddress1(trim(Input::get('address1')));
     $client->setAddress2(trim(Input::get('address2')));
     $client->setPrivateNotes(trim(Input::get('private_notes')));
     $resultado = $client->guardar();
     if (!$resultado) {
         $message = "Cliente actualizado con éxito";
         $client->save();
     } else {
         $url = 'clientes/create';
         Session::flash('error', $resultado);
         return Redirect::to($url)->withInput();
     }
     if (Input::has('contactos')) {
         // Actualizando contactos si existe
         $contactos = Utils::parseContactosUpdate(Input::get('contactos'));
         // return Response::json($contactos);
         $contactosBorrar = array();
         foreach ($contactos as $contacto) {
             if (!empty($contacto['id'])) {
                 $contactosBorrar[] = $contacto['id'];
             }
         }
         foreach ($client->contacts as $contact) {
             $sw = true;
             foreach ($contactos as $contacto) {
                 # code...
                 if (!empty($contacto['id'])) {
                     if ($contact->id == $contacto['id']) {
                         $contact->setFirstName(trim($contacto['first_name']));
                         $contact->setLastName(trim($contacto['last_name']));
                         $contact->setEmail(trim(strtolower($contacto['email'])));
                         $contact->setPhone(trim(strtolower($contacto['phone'])));
                         $contact->setPosition(trim($contacto['position']));
                         $contact->save();
                     }
                 }
             }
         }
         $primario = true;
         foreach ($contactos as $contacto) {
             # code...
             if (empty($contacto['id'])) {
                 $contact_new = Contact::createNew();
                 $contact_new->client_id = $client->getId();
                 $contact_new->setFirstName(trim($contacto['first_name']));
                 $contact_new->setLastName(trim($contacto['last_name']));
                 $contact_new->setEmail(trim(strtolower($contacto['email'])));
                 $contact_new->setPhone(trim(strtolower($contacto['phone'])));
                 $contact_new->setPosition(trim($contacto['position']));
                 $contact_new->setIsPrimary($primario);
                 $primario = false;
                 $resultado = $contact_new->guardar();
                 //print_r($resultado);
                 $client->contacts()->save($contact_new);
             }
         }
         foreach ($client->contacts as $contact) {
             # code...
             if (!in_array($contact->id, $contactosBorrar)) {
                 $contact->delete();
             }
         }
     } else {
         if ($client->contacts) {
             foreach ($client->contacts as $contacto) {
                 $contacto->delete();
                 # code...
             }
//.........这里部分代码省略.........
开发者ID:Vrian7ipx,项目名称:firstmed,代码行数:101,代码来源:ClientController.php

示例2: importFile

 private function importFile()
 {
     $data = Session::get('data');
     Session::forget('data');
     $map = Input::get('map');
     $count = 0;
     $hasHeaders = Input::get('header_checkbox');
     $countries = Country::remember(DEFAULT_QUERY_CACHE)->get();
     $countryMap = [];
     foreach ($countries as $country) {
         $countryMap[strtolower($country->name)] = $country->id;
     }
     foreach ($data as $row) {
         if ($hasHeaders) {
             $hasHeaders = false;
             continue;
         }
         $client = Client::createNew();
         $contact = Contact::createNew();
         $contact->is_primary = true;
         $contact->send_invoice = true;
         $count++;
         foreach ($row as $index => $value) {
             $field = $map[$index];
             $value = trim($value);
             if ($field == Client::$fieldVat_number && !$client->vat_number) {
                 $client->vat_number = $value;
             } else {
                 if ($field == Client::$fieldName && !$client->name) {
                     $client->name = $value;
                 } else {
                     if ($field == Client::$fieldNit && !$client->nit) {
                         $client->nit = $value;
                     } else {
                         if ($field == Client::$fieldPhone && !$client->work_phone) {
                             $client->work_phone = $value;
                         } else {
                             if ($field == Client::$fieldAddress1 && !$client->address1) {
                                 $client->address1 = $value;
                             } else {
                                 if ($field == Client::$fieldAddress2 && !$client->address2) {
                                     $client->address2 = $value;
                                 } else {
                                     if ($field == Client::$fieldNotes && !$client->private_notes) {
                                         $client->private_notes = $value;
                                     } else {
                                         if ($field == Contact::$fieldFirstName && !$contact->first_name) {
                                             $contact->first_name = $value;
                                         } else {
                                             if ($field == Contact::$fieldLastName && !$contact->last_name) {
                                                 $contact->last_name = $value;
                                             } else {
                                                 if ($field == Contact::$fieldPhone && !$contact->phone) {
                                                     $contact->phone = $value;
                                                 } else {
                                                     if ($field == Contact::$fieldEmail && !$contact->email) {
                                                         $contact->email = strtolower($value);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $client->save();
         $client->contacts()->save($contact);
         $client->save();
         Activity::createClient($client, false);
     }
     $message = Utils::pluralize('created_client', $count);
     Session::flash('message', $message);
     return Redirect::to('clients');
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:78,代码来源:AccountController.php

示例3: saveClient

 public function saveClient($publicId, $data, $notify = true)
 {
     if (!$publicId || $publicId == "-1") {
         $client = Client::createNew();
         $client->currency_id = 1;
         $contact = Contact::createNew();
         $contact->is_primary = true;
         $contact->send_invoice = true;
     } else {
         $client = Client::scope($publicId)->with('contacts')->first();
         $contact = $client->contacts()->where('is_primary', '=', true)->first();
     }
     if (isset($data['nit'])) {
         $client->nit = trim($data['nit']);
     }
     if (isset($data['name'])) {
         $client->name = trim($data['name']);
     }
     if (isset($data['business_name'])) {
         $client->business_name = trim($data['business_name']);
     }
     if (isset($data['work_phone'])) {
         $client->work_phone = trim($data['work_phone']);
     }
     if (isset($data['custom_value1'])) {
         $client->custom_value1 = trim($data['custom_value1']);
     }
     if (isset($data['custom_value2'])) {
         $client->custom_value2 = trim($data['custom_value2']);
     }
     if (isset($data['address1'])) {
         $client->address1 = trim($data['address1']);
     }
     if (isset($data['address2'])) {
         $client->address2 = trim($data['address2']);
     }
     if (isset($data['city'])) {
         $client->city = trim($data['city']);
     }
     if (isset($data['state'])) {
         $client->state = trim($data['state']);
     }
     if (isset($data['private_notes'])) {
         $client->private_notes = trim($data['private_notes']);
     }
     $client->save();
     $isPrimary = true;
     $contactIds = [];
     if (isset($data['contact'])) {
         $info = $data['contact'];
         if (isset($info['email'])) {
             $contact->email = trim(strtolower($info['email']));
         }
         if (isset($info['first_name'])) {
             $contact->first_name = trim($info['first_name']);
         }
         if (isset($info['last_name'])) {
             $contact->last_name = trim($info['last_name']);
         }
         if (isset($info['phone'])) {
             $contact->phone = trim($info['phone']);
         }
         $contact->is_primary = true;
         $contact->send_invoice = true;
         $client->contacts()->save($contact);
     } else {
         foreach ($data['contacts'] as $record) {
             $record = (array) $record;
             if ($publicId != "-1" && isset($record['public_id']) && $record['public_id']) {
                 $contact = Contact::scope($record['public_id'])->first();
             } else {
                 $contact = Contact::createNew();
             }
             if (isset($record['email'])) {
                 $contact->email = trim(strtolower($record['email']));
             }
             if (isset($record['first_name'])) {
                 $contact->first_name = trim($record['first_name']);
             }
             if (isset($record['last_name'])) {
                 $contact->last_name = trim($record['last_name']);
             }
             if (isset($record['phone'])) {
                 $contact->phone = trim($record['phone']);
             }
             $contact->is_primary = $isPrimary;
             $contact->send_invoice = isset($record['send_invoice']) ? $record['send_invoice'] : true;
             $isPrimary = false;
             $client->contacts()->save($contact);
             $contactIds[] = $contact->public_id;
         }
         foreach ($client->contacts as $contact) {
             if (!in_array($contact->public_id, $contactIds)) {
                 $contact->delete();
             }
         }
     }
     $client->save();
     if (!$publicId || $publicId == "-1") {
         \Activity::createClient($client, $notify);
//.........这里部分代码省略.........
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:101,代码来源:invoiceController.php

示例4: save

 private function save($publicId = null)
 {
     $rules = array('email' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $url = $publicId ? 'clients/' . $publicId . '/edit' : 'clients/create';
         return Redirect::to($url)->withErrors($validator)->withInput(Input::except('password'));
     } else {
         if ($publicId) {
             $client = Client::scope($publicId)->firstOrFail();
         } else {
             $client = Client::createNew();
         }
         $client->name = trim(Input::get('name'));
         $client->id_number = trim(Input::get('id_number'));
         $client->vat_number = trim(Input::get('vat_number'));
         $client->work_phone = trim(Input::get('work_phone'));
         $client->custom_value1 = trim(Input::get('custom_value1'));
         $client->custom_value2 = trim(Input::get('custom_value2'));
         $client->address1 = trim(Input::get('address1'));
         $client->address2 = trim(Input::get('address2'));
         $client->city = trim(Input::get('city'));
         $client->state = trim(Input::get('state'));
         $client->postal_code = trim(Input::get('postal_code'));
         $client->country_id = Input::get('country_id') ?: null;
         $client->private_notes = trim(Input::get('private_notes'));
         $client->size_id = Input::get('size_id') ?: null;
         $client->industry_id = Input::get('industry_id') ?: null;
         $client->currency_id = Input::get('currency_id') ?: null;
         $client->payment_terms = Input::get('payment_terms') ?: 0;
         $client->website = trim(Input::get('website'));
         $client->save();
         $data = json_decode(Input::get('data'));
         $contactIds = [];
         $isPrimary = true;
         foreach ($data->contacts as $contact) {
             if (isset($contact->public_id) && $contact->public_id) {
                 $record = Contact::scope($contact->public_id)->firstOrFail();
             } else {
                 $record = Contact::createNew();
             }
             $record->email = trim(strtolower($contact->email));
             $record->first_name = trim($contact->first_name);
             $record->last_name = trim($contact->last_name);
             $record->phone = trim($contact->phone);
             $record->is_primary = $isPrimary;
             $isPrimary = false;
             $client->contacts()->save($record);
             $contactIds[] = $record->public_id;
         }
         foreach ($client->contacts as $contact) {
             if (!in_array($contact->public_id, $contactIds)) {
                 $contact->delete();
             }
         }
         if ($publicId) {
             Session::flash('message', trans('texts.updated_client'));
         } else {
             Activity::createClient($client);
             Session::flash('message', trans('texts.created_client'));
         }
         return Redirect::to('clients/' . $client->public_id);
     }
 }
开发者ID:stewartadam,项目名称:invoice-ninja,代码行数:64,代码来源:ClientController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     // return Response::json(Input::all());
     // return Response::json($contactos);
     $client = Client::where('id', $id)->first();
     $client->setNit(trim(Input::get('nit')));
     $client->setName(trim(Input::get('name')));
     $client->setBussinesName(trim(Input::get('business_name')));
     $client->setWorkPhone(trim(Input::get('work_phone')));
     $client->setCustomValue1(trim(Input::get('l1')));
     $client->setCustomValue2(trim(Input::get('l2')));
     $client->setCustomValue3(trim(Input::get('l3')));
     $client->setCustomValue4(trim(Input::get('l4')));
     $client->setCustomValue5(trim(Input::get('l5')));
     $client->setCustomValue6(trim(Input::get('l6')));
     //		$client->setCustomValue7(trim(Input::get('custom_value7')));
     //		$client->setCustomValue8(trim(Input::get('custom_value8')));
     //		$client->setCustomValue9(trim(Input::get('custom_value9')));
     //		$client->setCustomValue10(trim(Input::get('custom_value10')));
     //		$client->setCustomValue11(trim(Input::get('custom_value11')));
     //		$client->setCustomValue12(trim(Input::get('custom_value12')));
     $client->setAddress1(trim(Input::get('address1')));
     $client->setAddress2(trim(Input::get('address2')));
     $client->setPrivateNotes(trim(Input::get('private_notes')));
     //improve this put method
     $client->other = trim(Input::get('other'));
     $client->setZone(trim(Input::get('zone')));
     $client->setCity(trim(Input::get('city')));
     $client->setGroup(trim(Input::get('group')));
     $client->setBusiness_type_id(trim(Input::get('business')));
     $dias = "";
     for ($i = 1; $i < 8; $i++) {
         if (Input::get('d' . $i)) {
             $dias .= "1";
         } else {
             $dias .= "0";
         }
     }
     //frecuency es handed with 0 and 1
     $client->frecuency = $dias;
     // return Response::json($client);
     $resultado = $client->guardar();
     $client->frecuency = $dias;
     $client->save();
     if (!$resultado) {
         $message = "Cliente actualizado con éxito";
         $client->save();
     } else {
         $url = 'clientes/create';
         Session::flash('error', $resultado);
         return Redirect::to($url)->withInput();
     }
     if (Input::has('contactos')) {
         // Actualizando contactos si existe
         $contactos = Utils::parseContactosUpdate(Input::get('contactos'));
         $contactosBorrar = array();
         foreach ($contactos as $contacto) {
             if (!empty($contacto['id'])) {
                 $contactosBorrar[] = $contacto['id'];
             }
         }
         foreach ($client->contacts as $contact) {
             $sw = true;
             foreach ($contactos as $contacto) {
                 # code...
                 if (!empty($contacto['id'])) {
                     if ($contact->id == $contacto['id']) {
                         $contact->setFirstName(trim($contacto['first_name']));
                         $contact->setLastName(trim($contacto['last_name']));
                         $contact->setEmail(trim(strtolower($contacto['email'])));
                         $contact->setPhone(trim(strtolower($contacto['phone'])));
                         $contact->save();
                     }
                 }
             }
         }
         $primario = true;
         foreach ($contactos as $contacto) {
             # code...
             if (empty($contacto['id'])) {
                 $contact_new = Contact::createNew();
                 $contact_new->client_id = $client->getId();
                 $contact_new->setFirstName(trim($contacto['first_name']));
                 $contact_new->setLastName(trim($contacto['last_name']));
                 $contact_new->setEmail(trim(strtolower($contacto['email'])));
                 $contact_new->setPhone(trim(strtolower($contacto['phone'])));
                 $contact_new->setIsPrimary($primario);
                 $primario = false;
                 $resultado = $contact_new->guardar();
                 //print_r($resultado);
                 $client->contacts()->save($contact_new);
             }
         }
         foreach ($client->contacts as $contact) {
//.........这里部分代码省略.........
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:101,代码来源:ClientController.php

示例6: save

 private function save($publicId = null, $isPos = null)
 {
     $rules = array('nit' => 'required');
     // $clientId =  $publicId ? Client::getPrivateId($publicId) : null;
     // 		$rules = ['nit' => 'unique:clients,nit,' . $clientId . ',id,account_id,' . Auth::user()->account_id];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         if ($isPos) {
             $datos = array('resultado' => 1, 'mensaje' => 'Nit ya ha sido registrado.');
             return Response::json($datos);
         } else {
             $url = $publicId ? 'clients/' . $publicId . '/edit' : 'clients/create';
             return Redirect::to($url)->withErrors($validator)->withInput(Input::except('password'));
         }
     } else {
         if ($publicId) {
             $client = Client::scope($publicId)->firstOrFail();
         } else {
             $client = Client::createNew();
         }
         $client->nit = trim(Input::get('nit'));
         $client->name = trim(Input::get('name'));
         $client->business_name = trim(Input::get('business_name'));
         $client->work_phone = trim(Input::get('work_phone'));
         if ($isPos) {
             $client->business_name = trim(Input::get('name'));
         }
         $client->custom_value1 = trim(Input::get('custom_value1'));
         $client->custom_value2 = trim(Input::get('custom_value2'));
         $client->custom_value3 = trim(Input::get('custom_value3'));
         $client->custom_value4 = trim(Input::get('custom_value4'));
         $client->custom_value5 = trim(Input::get('custom_value5'));
         $client->custom_value6 = trim(Input::get('custom_value6'));
         $client->custom_value7 = trim(Input::get('custom_value7'));
         $client->custom_value8 = trim(Input::get('custom_value8'));
         $client->custom_value9 = trim(Input::get('custom_value9'));
         $client->custom_value10 = trim(Input::get('custom_value10'));
         $client->custom_value11 = trim(Input::get('custom_value11'));
         $client->custom_value12 = trim(Input::get('custom_value12'));
         $client->address1 = trim(Input::get('address1'));
         $client->address2 = trim(Input::get('address2'));
         $client->city = trim(Input::get('city'));
         $client->state = trim(Input::get('state'));
         $client->private_notes = trim(Input::get('private_notes'));
         $client->save();
         if (!$isPos) {
             $data = json_decode(Input::get('data'));
             $contactIds = [];
             $isPrimary = true;
             foreach ($data->contacts as $contact) {
                 if (isset($contact->public_id) && $contact->public_id) {
                     $record = Contact::scope($contact->public_id)->firstOrFail();
                 } else {
                     $record = Contact::createNew();
                 }
                 $record->email = trim(strtolower($contact->email));
                 $record->first_name = trim($contact->first_name);
                 $record->last_name = trim($contact->last_name);
                 $record->phone = trim($contact->phone);
                 $record->is_primary = $isPrimary;
                 $isPrimary = false;
                 $client->contacts()->save($record);
                 $contactIds[] = $record->public_id;
             }
             foreach ($client->contacts as $contact) {
                 if (!in_array($contact->public_id, $contactIds)) {
                     $contact->delete();
                 }
             }
             if ($publicId) {
                 Activity::editClient($client);
                 Session::flash('message', trans('texts.updated_client'));
             } else {
                 Activity::createClient($client);
                 Session::flash('message', trans('texts.created_client'));
             }
             return Redirect::to('clients/' . $client->public_id);
         } else {
             $record = Contact::createNew();
             $record->is_primary = true;
             $client->contacts()->save($record);
             $clientPOS = array('id' => $client->id, 'public_id' => $client->public_id, 'name' => $client->name, 'nit' => $client->nit, 'business_name' => $client->business_name);
             $datos = array('resultado' => 0, 'cliente' => $clientPOS);
             return Response::json($datos);
         }
     }
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:87,代码来源:ClientController.php

示例7: doImportClients

 public function doImportClients()
 {
     $data = Session::get('data');
     Session::forget('data');
     $map = Input::get('map');
     $count = 0;
     $first = true;
     foreach ($data as $row) {
         if ($first) {
             $first = false;
             continue;
         }
         $client = Client::createNew();
         $contact = Contact::createNew();
         $contact->is_primary = true;
         $contact->send_invoice = true;
         $count++;
         foreach ($row as $index => $value) {
             $field = $map[$index];
             $value = trim($value);
             if ($field == Client::$fieldName && !$client->name) {
                 $client->name = $value;
             } else {
                 if ($field == Client::$fieldBusinessName && !$client->business_name) {
                     $client->business_name = $value;
                 } else {
                     if ($field == Client::$fieldNit && !$client->nit) {
                         $client->nit = $value;
                     } else {
                         if ($field == Client::$fieldAddress1 && !$client->address1) {
                             $client->address1 = $value;
                         } else {
                             if ($field == Client::$fieldAddress2 && !$client->address2) {
                                 $client->address2 = $value;
                             } else {
                                 if ($field == Client::$fieldWorkPhone && !$client->work_phone) {
                                     $client->work_phone = $value;
                                 } else {
                                     if ($field == Client::$fieldPrivateNotes && !$client->private_notes) {
                                         $client->private_notes = $value;
                                     } else {
                                         if ($field == Contact::$fieldFirstName && !$contact->first_name) {
                                             $contact->first_name = $value;
                                         } else {
                                             if ($field == Contact::$fieldLastName && !$contact->last_name) {
                                                 $contact->last_name = $value;
                                             } else {
                                                 if ($field == Contact::$fieldPhone && !$contact->phone) {
                                                     $contact->phone = $value;
                                                 } else {
                                                     if ($field == Contact::$fieldEmail && !$contact->email) {
                                                         $contact->email = strtolower($value);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $client->save();
         $client->contacts()->save($contact);
         $client->save();
         // Activity::createClient($client, false);
     }
     $message = $count == 1 ? 'cliente creado con éxito' : $count . 'clientes creados con éxito';
     Session::flash('message', $message);
     return Redirect::to('clientes');
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:73,代码来源:ImportController.php

示例8: fire

 public function fire()
 {
     $this->info(date('Y-m-d') . ' Running CreateRandomData...');
     $user = User::first();
     if (!$user) {
         $this->error("Error: please create user account by logging in");
         return;
     }
     $productNames = ['Arkansas', 'New York', 'Arizona', 'California', 'Colorado', 'Alabama', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'Alaska', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
     $clientNames = ['IBM', 'Nestle', 'Mitsubishi UFJ Financial', 'Vodafone', 'Eni', 'Procter & Gamble', 'Johnson & Johnson', 'American International Group', 'Banco Santander', 'BHP Billiton', 'Pfizer', 'Itaú Unibanco Holding', 'Ford Motor', 'BMW Group', 'Commonwealth Bank', 'EDF', 'Statoil', 'Google', 'Siemens', 'Novartis', 'Royal Bank of Canada', 'Sumitomo Mitsui Financial', 'Comcast', 'Sberbank', 'Goldman Sachs Group', 'Westpac Banking Group', 'Nippon Telegraph & Tel', 'Ping An Insurance Group', 'Banco Bradesco', 'Anheuser-Busch InBev', 'Bank of Communications', 'China Life Insurance', 'General Motors', 'Telefónica', 'MetLife', 'Honda Motor', 'Enel', 'BASF', 'Softbank', 'National Australia Bank', 'ANZ', 'ConocoPhillips', 'TD Bank Group', 'Intel', 'UBS', 'Hewlett-Packard', 'Coca-Cola', 'Cisco Systems', 'UnitedHealth Group', 'Boeing', 'Zurich Insurance Group', 'Hyundai Motor', 'Sanofi', 'Credit Agricole', 'United Technologies', 'Roche Holding', 'Munich Re', 'PepsiCo', 'Oracle', 'Bank of Nova Scotia'];
     foreach ($productNames as $i => $value) {
         $product = Product::createNew($user);
         $product->id = $i + 1;
         $product->product_key = $value;
         $product->save();
     }
     foreach ($clientNames as $i => $value) {
         $client = Client::createNew($user);
         $client->name = $value;
         $client->save();
         $contact = Contact::createNew($user);
         $contact->email = "client@aol.com";
         $contact->is_primary = 1;
         $client->contacts()->save($contact);
         $numInvoices = rand(1, 25);
         if ($numInvoices == 4 || $numInvoices == 10 || $numInvoices == 25) {
             // leave these
         } else {
             if ($numInvoices % 3 == 0) {
                 $numInvoices = 1;
             } else {
                 if ($numInvoices > 10) {
                     $numInvoices = $numInvoices % 2;
                 }
             }
         }
         $paidUp = rand(0, 1) == 1;
         for ($j = 1; $j <= $numInvoices; $j++) {
             $price = rand(10, 1000);
             if ($price < 900) {
                 $price = rand(10, 150);
             }
             $invoice = Invoice::createNew($user);
             $invoice->invoice_number = $user->account->getNextInvoiceNumber();
             $invoice->amount = $invoice->balance = $price;
             $invoice->created_at = date('Y-m-d', strtotime(date("Y-m-d") . ' - ' . rand(1, 100) . ' days'));
             $client->invoices()->save($invoice);
             $productId = rand(0, 40);
             if ($productId > 20) {
                 $productId = $productId % 2 + rand(0, 2);
             }
             $invoiceItem = InvoiceItem::createNew($user);
             $invoiceItem->product_id = $productId + 1;
             $invoiceItem->product_key = $productNames[$invoiceItem->product_id];
             $invoiceItem->cost = $invoice->amount;
             $invoiceItem->qty = 1;
             $invoice->invoice_items()->save($invoiceItem);
             if ($paidUp || rand(0, 2) > 1) {
                 $payment = Payment::createNew($user);
                 $payment->invoice_id = $invoice->id;
                 $payment->amount = $invoice->amount;
                 $client->payments()->save($payment);
             }
         }
     }
 }
开发者ID:njmube,项目名称:invoice-ninja,代码行数:66,代码来源:CreateRandomData.php

示例9: createEntity

 public function createEntity()
 {
     return Contact::createNew();
 }
开发者ID:linkorb,项目名称:contactbase-client-php,代码行数:4,代码来源:ApiContactRepository.php

示例10: registrarCliente

 public function registrarCliente()
 {
     $data = Input::all();
     // $data  = array('hola' => 'mundo' );
     $client = Client::createNew();
     $contact = Contact::createNew();
     $contact->is_primary = true;
     $client->name = trim($data['name']);
     $client->nit = trim($data['nit']);
     $client->save();
     $email = $data['email'];
     if ($email == 'sinemail') {
         // $email = "david@david.corp";
         $user_id = Auth::user()->getAuthIdentifier();
         $user = DB::table('users')->select('account_id')->where('id', $user_id)->first();
         $account_id = $user->account_id;
         $account = DB::table('accounts')->select('work_email')->where('id', $account_id)->first();
         $email = $account->work_email;
     }
     $isPrimary = true;
     $contact->email = trim(strtolower($email));
     $contact->phone = trim($data['phone']);
     $contact->is_primary = $isPrimary;
     $client->contacts()->save($contact);
     $cliente = DB::table('clients')->select('id', 'name', 'nit')->where('account_id', $client->account_id)->where('nit', $client->nit)->first();
     $datos = array('resultado' => 0, 'cliente' => $cliente);
     return Response::json($datos);
     // return Response::json($client);
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:29,代码来源:ClientController.php


注:本文中的Contact::createNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。