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


PHP Contact::scope方法代码示例

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


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

示例1: getData

 private function getData($request)
 {
     $account = Auth::user()->account;
     $data = ['account' => $account, 'title' => 'Invoice Ninja v' . NINJA_VERSION . ' - ' . $account->formatDateTime($account->getDateTime()), 'multiUser' => $account->users->count() > 1];
     if ($request->input(ENTITY_CLIENT)) {
         $data['clients'] = Client::scope()->with('user', 'contacts', 'country')->withArchived()->get();
         $data['contacts'] = Contact::scope()->with('user', 'client.contacts')->withTrashed()->get();
         $data['credits'] = Credit::scope()->with('user', 'client.contacts')->get();
     }
     if ($request->input(ENTITY_TASK)) {
         $data['tasks'] = Task::scope()->with('user', 'client.contacts')->withArchived()->get();
     }
     if ($request->input(ENTITY_INVOICE)) {
         $data['invoices'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_quote', '=', false)->where('is_recurring', '=', false)->get();
         $data['quotes'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_quote', '=', true)->where('is_recurring', '=', false)->get();
         $data['recurringInvoices'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status', 'frequency')->withArchived()->where('is_quote', '=', false)->where('is_recurring', '=', true)->get();
     }
     if ($request->input(ENTITY_PAYMENT)) {
         $data['payments'] = Payment::scope()->withArchived()->with('user', 'client.contacts', 'payment_type', 'invoice', 'account_gateway.gateway')->get();
     }
     if ($request->input(ENTITY_VENDOR)) {
         $data['clients'] = Vendor::scope()->with('user', 'vendorcontacts', 'country')->withArchived()->get();
         $data['vendor_contacts'] = VendorContact::scope()->with('user', 'vendor.contacts')->withTrashed()->get();
         /*
         $data['expenses'] = Credit::scope()
             ->with('user', 'client.contacts')
             ->get();
         */
     }
     return $data;
 }
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:31,代码来源:ExportController.php

示例2: addContact

 public function addContact($data, $isPrimary = false)
 {
     $publicId = isset($data['public_id']) ? $data['public_id'] : false;
     if ($publicId && $publicId != '-1') {
         $contact = Contact::scope($publicId)->firstOrFail();
     } else {
         $contact = Contact::createNew();
         $contact->send_invoice = true;
     }
     $contact->fill($data);
     $contact->is_primary = $isPrimary;
     return $this->contacts()->save($contact);
 }
开发者ID:nacef-labidi,项目名称:invoiceninja,代码行数:13,代码来源:Client.php

示例3: save

 public function save($data)
 {
     $publicId = isset($data['public_id']) ? $data['public_id'] : false;
     if (!$publicId || $publicId == '-1') {
         $contact = Contact::createNew();
         $contact->send_invoice = true;
         $contact->client_id = $data['client_id'];
         $contact->is_primary = Contact::scope()->where('client_id', '=', $contact->client_id)->count() == 0;
     } else {
         $contact = Contact::scope($publicId)->firstOrFail();
     }
     $contact->fill($data);
     $contact->save();
     return $contact;
 }
开发者ID:lingxuan630,项目名称:invoiceninja,代码行数:15,代码来源:ContactRepository.php

示例4: addContact

 public function addContact($data, $isPrimary = false)
 {
     $publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false);
     if ($publicId && $publicId != '-1') {
         $contact = Contact::scope($publicId)->firstOrFail();
     } else {
         $contact = Contact::createNew();
         $contact->send_invoice = true;
     }
     if (Utils::hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $this->account->enable_portal_password) {
         if (!empty($data['password']) && $data['password'] != '-%unchanged%-') {
             $contact->password = bcrypt($data['password']);
         } else {
             if (empty($data['password'])) {
                 $contact->password = null;
             }
         }
     }
     $contact->fill($data);
     $contact->is_primary = $isPrimary;
     return $this->contacts()->save($contact);
 }
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:22,代码来源:Client.php

示例5: export

 private function export()
 {
     $output = fopen('php://output', 'w') or Utils::fatalError();
     header('Content-Type:application/csv');
     header('Content-Disposition:attachment;filename=export.csv');
     $clients = Client::scope()->get();
     Utils::exportData($output, $clients->toArray());
     $contacts = Contact::scope()->get();
     Utils::exportData($output, $contacts->toArray());
     $invoices = Invoice::scope()->get();
     Utils::exportData($output, $invoices->toArray());
     $invoiceItems = InvoiceItem::scope()->get();
     Utils::exportData($output, $invoiceItems->toArray());
     $payments = Payment::scope()->get();
     Utils::exportData($output, $payments->toArray());
     $credits = Credit::scope()->get();
     Utils::exportData($output, $credits->toArray());
     fclose($output);
     exit;
 }
开发者ID:jirislam,项目名称:invoice-ninja,代码行数:20,代码来源:AccountController.php

示例6: save

 private function save($publicId = null)
 {
     $rules = array('email' => 'email|required_without:first_name', 'first_name' => 'required_without:email');
     $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($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:njmube,项目名称:invoice-ninja,代码行数:64,代码来源:ClientController.php

示例7: getData

 /**
  * @param $request
  *
  * @return array
  */
 private function getData($request)
 {
     $account = Auth::user()->account;
     $data = ['account' => $account, 'title' => 'Invoice Ninja v' . NINJA_VERSION . ' - ' . $account->formatDateTime($account->getDateTime()), 'multiUser' => $account->users->count() > 1];
     if ($request->input('include') === 'all' || $request->input('clients')) {
         $data['clients'] = Client::scope()->with('user', 'contacts', 'country')->withArchived()->get();
     }
     if ($request->input('include') === 'all' || $request->input('contacts')) {
         $data['contacts'] = Contact::scope()->with('user', 'client.contacts')->withTrashed()->get();
     }
     if ($request->input('include') === 'all' || $request->input('credits')) {
         $data['credits'] = Credit::scope()->with('user', 'client.contacts')->get();
     }
     if ($request->input('include') === 'all' || $request->input('tasks')) {
         $data['tasks'] = Task::scope()->with('user', 'client.contacts')->withArchived()->get();
     }
     if ($request->input('include') === 'all' || $request->input('invoices')) {
         $data['invoices'] = Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_recurring', '=', false)->get();
     }
     if ($request->input('include') === 'all' || $request->input('quotes')) {
         $data['quotes'] = Invoice::scope()->invoiceType(INVOICE_TYPE_QUOTE)->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_recurring', '=', false)->get();
     }
     if ($request->input('include') === 'all' || $request->input('recurring')) {
         $data['recurringInvoices'] = Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->with('user', 'client.contacts', 'invoice_status', 'frequency')->withArchived()->where('is_recurring', '=', true)->get();
     }
     if ($request->input('include') === 'all' || $request->input('payments')) {
         $data['payments'] = Payment::scope()->withArchived()->with('user', 'client.contacts', 'payment_type', 'invoice', 'account_gateway.gateway')->get();
     }
     if ($request->input('include') === 'all' || $request->input('vendors')) {
         $data['vendors'] = Vendor::scope()->with('user', 'vendor_contacts', 'country')->withArchived()->get();
     }
     if ($request->input('include') === 'all' || $request->input('vendor_contacts')) {
         $data['vendor_contacts'] = VendorContact::scope()->with('user', 'vendor.vendor_contacts')->withTrashed()->get();
     }
     return $data;
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:41,代码来源:ExportController.php

示例8: findPhonetically

 public function findPhonetically($clientName)
 {
     $clientNameMeta = metaphone($clientName);
     $map = [];
     $max = SIMILAR_MIN_THRESHOLD;
     $clientId = 0;
     $clients = Client::scope()->get(['id', 'name', 'public_id']);
     foreach ($clients as $client) {
         $map[$client->id] = $client;
         if (!$client->name) {
             continue;
         }
         $similar = similar_text($clientNameMeta, metaphone($client->name), $percent);
         if ($percent > $max) {
             $clientId = $client->id;
             $max = $percent;
         }
     }
     $contacts = Contact::scope()->get(['client_id', 'first_name', 'last_name', 'public_id']);
     foreach ($contacts as $contact) {
         if (!$contact->getFullName() || !isset($map[$contact->client_id])) {
             continue;
         }
         $similar = similar_text($clientNameMeta, metaphone($contact->getFullName()), $percent);
         if ($percent > $max) {
             $clientId = $contact->client_id;
             $max = $percent;
         }
     }
     return $clientId && isset($map[$clientId]) ? $map[$clientId] : null;
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:31,代码来源:ClientRepository.php

示例9: save

 public function save($publicId, $data, $notify = true)
 {
     if (!$publicId || $publicId == "-1") {
         $client = Client::createNew();
         $contact = Contact::createNew();
         $contact->is_primary = true;
         $contact->send_invoice = true;
     } else {
         $client = Client::scope($publicId)->with('contacts')->firstOrFail();
         $contact = $client->contacts()->where('is_primary', '=', true)->firstOrFail();
     }
     if (isset($data['name'])) {
         $client->name = trim($data['name']);
     }
     if (isset($data['id_number'])) {
         $client->id_number = trim($data['id_number']);
     }
     if (isset($data['vat_number'])) {
         $client->vat_number = trim($data['vat_number']);
     }
     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['postal_code'])) {
         $client->postal_code = trim($data['postal_code']);
     }
     if (isset($data['country_id'])) {
         $client->country_id = $data['country_id'] ? $data['country_id'] : null;
     }
     if (isset($data['private_notes'])) {
         $client->private_notes = trim($data['private_notes']);
     }
     if (isset($data['size_id'])) {
         $client->size_id = $data['size_id'] ? $data['size_id'] : null;
     }
     if (isset($data['industry_id'])) {
         $client->industry_id = $data['industry_id'] ? $data['industry_id'] : null;
     }
     if (isset($data['currency_id'])) {
         $client->currency_id = $data['currency_id'] ? $data['currency_id'] : null;
     }
     if (isset($data['language_id'])) {
         $client->language_id = $data['language_id'] ? $data['language_id'] : null;
     }
     if (isset($data['payment_terms'])) {
         $client->payment_terms = $data['payment_terms'];
     }
     if (isset($data['website'])) {
         $client->website = trim($data['website']);
     }
     $client->save();
     $isPrimary = true;
     $contactIds = [];
     if (isset($data['contact'])) {
         $info = $data['contact'];
         if (isset($info['email'])) {
             $contact->email = trim($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'])->firstOrFail();
             } else {
                 $contact = Contact::createNew();
             }
             if (isset($record['email'])) {
                 $contact->email = trim($record['email']);
             }
             if (isset($record['first_name'])) {
//.........这里部分代码省略.........
开发者ID:nafrente,项目名称:invoice-ninja,代码行数:101,代码来源:ClientRepository.php


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