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


PHP Client::scope方法代码示例

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


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

示例1: edit

 public function edit($publicId)
 {
     $payment = Payment::scope($publicId)->firstOrFail();
     $payment->payment_date = Utils::fromSqlDate($payment->payment_date);
     $data = array('client' => null, 'invoice' => null, 'invoices' => Invoice::scope()->where('is_recurring', '=', false)->where('is_quote', '=', false)->with('client', 'invoice_status')->orderBy('invoice_number')->get(), 'payment' => $payment, 'method' => 'PUT', 'url' => 'payments/' . $publicId, 'title' => trans('texts.edit_payment'), 'paymentTypes' => Cache::get('paymentTypes'), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
     return View::make('payments.edit', $data);
 }
开发者ID:joshuadwire,项目名称:invoiceninja,代码行数:7,代码来源:PaymentController.php

示例2: 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

示例3: edit

 public function edit($publicId)
 {
     $credit = Credit::scope($publicId)->firstOrFail();
     $credit->credit_date = Utils::fromSqlDate($credit->credit_date);
     $data = array('client' => null, 'credit' => $credit, 'method' => 'PUT', 'url' => 'credits/' . $publicId, 'title' => 'Edit Credit', 'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
     return View::make('credit.edit', $data);
 }
开发者ID:n-a-m-e,项目名称:invoice-ninja,代码行数:7,代码来源:CreditController.php

示例4: save

 public function save($data)
 {
     $publicId = isset($data['public_id']) ? $data['public_id'] : false;
     if (!$publicId || $publicId == '-1') {
         $client = Client::createNew();
     } else {
         $client = Client::scope($publicId)->with('contacts')->firstOrFail();
     }
     $client->fill($data);
     $client->save();
     /*
     if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
         return $client;
     }
     */
     $first = true;
     $contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
     $contactIds = [];
     foreach ($contacts as $contact) {
         $contact = $client->addContact($contact, $first);
         $contactIds[] = $contact->public_id;
         $first = false;
     }
     foreach ($client->contacts as $contact) {
         if (!in_array($contact->public_id, $contactIds)) {
             $contact->delete();
         }
     }
     return $client;
 }
开发者ID:CyBeRoni,项目名称:invoiceninja,代码行数:30,代码来源:ClientRepository.php

示例5: store

 /**
  * @SWG\Post(
  *   path="/clients",
  *   tags={"client"},
  *   summary="Create a client",
  *   @SWG\Parameter(
  *     in="body",
  *     name="body",
  *     @SWG\Schema(ref="#/definitions/Client")
  *   ),
  *   @SWG\Response(
  *     response=200,
  *     description="New client",
  *      @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client"))
  *   ),
  *   @SWG\Response(
  *     response="default",
  *     description="an ""unexpected"" error"
  *   )
  * )
  */
 public function store(CreateClientRequest $request)
 {
     $client = $this->clientRepo->save($request->input());
     $client = Client::scope($client->public_id)->with('country', 'contacts', 'industry', 'size', 'currency')->first();
     $transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
     $data = $this->createItem($client, $transformer, ENTITY_CLIENT);
     return $this->response($data);
 }
开发者ID:magicians,项目名称:invoiceninja,代码行数:29,代码来源:ClientApiController.php

示例6: index

 public function index()
 {
     $clients = Client::scope()->with('contacts')->orderBy('created_at', 'desc')->get();
     $clients = Utils::remapPublicIds($clients->toArray());
     $response = json_encode($clients, JSON_PRETTY_PRINT);
     $headers = Utils::getApiHeaders(count($clients));
     return Response::make($response, 200, $headers);
 }
开发者ID:ricoa,项目名称:invoice-ninja,代码行数:8,代码来源:ClientApiController.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check() && Client::scope()->count() > 0) {
         Session::reflash();
         return new RedirectResponse(url('/dashboard'));
     }
     return $next($request);
 }
开发者ID:magicians,项目名称:invoiceninja,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例8: store

 /**
  * @SWG\Post(
  *   path="/clients",
  *   tags={"client"},
  *   summary="Create a client",
  *   @SWG\Parameter(
  *     in="body",
  *     name="body",
  *     @SWG\Schema(ref="#/definitions/Client")
  *   ),
  *   @SWG\Response(
  *     response=200,
  *     description="New client",
  *      @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client"))
  *   ),
  *   @SWG\Response(
  *     response="default",
  *     description="an ""unexpected"" error"
  *   )
  * )
  */
 public function store(CreateClientRequest $request)
 {
     $client = $this->clientRepo->save($request->input());
     $client = Client::scope($client->public_id)->with('country', 'contacts', 'industry', 'size', 'currency')->first();
     $client = Utils::remapPublicIds([$client]);
     $response = json_encode($client, JSON_PRETTY_PRINT);
     $headers = Utils::getApiHeaders();
     return Response::make($response, 200, $headers);
 }
开发者ID:jargij,项目名称:invoiceninja,代码行数:30,代码来源:ClientApiController.php

示例9: index

 /**
  * @SWG\Get(
  *   path="/clients",
  *   summary="List of clients",
  *   tags={"client"},
  *   @SWG\Response(
  *     response=200,
  *     description="A list with clients",
  *      @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Client"))
  *   ),
  *   @SWG\Response(
  *     response="default",
  *     description="an ""unexpected"" error"
  *   )
  * )
  */
 public function index()
 {
     $clients = Client::scope()->orderBy('created_at', 'desc')->withTrashed();
     // Filter by email
     if ($email = Input::get('email')) {
         $clients = $clients->whereHas('contacts', function ($query) use($email) {
             $query->where('email', $email);
         });
     }
     return $this->listResponse($clients);
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:27,代码来源:ClientApiController.php

示例10: save

 public function save($data, $client = null)
 {
     $publicId = isset($data['public_id']) ? $data['public_id'] : false;
     if ($client) {
         // do nothing
     } elseif (!$publicId || $publicId == '-1') {
         $client = Client::createNew();
     } else {
         $client = Client::scope($publicId)->with('contacts')->firstOrFail();
         \Log::warning('Entity not set in client repo save');
     }
     // convert currency code to id
     if (isset($data['currency_code'])) {
         $currencyCode = strtolower($data['currency_code']);
         $currency = Cache::get('currencies')->filter(function ($item) use($currencyCode) {
             return strtolower($item->code) == $currencyCode;
         })->first();
         if ($currency) {
             $data['currency_id'] = $currency->id;
         }
     }
     $client->fill($data);
     $client->save();
     /*
     if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
         return $client;
     }
     */
     $first = true;
     $contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
     $contactIds = [];
     // If the primary is set ensure it's listed first
     usort($contacts, function ($left, $right) {
         return (isset($right['is_primary']) ? $right['is_primary'] : 1) - (isset($left['is_primary']) ? $left['is_primary'] : 0);
     });
     foreach ($contacts as $contact) {
         $contact = $client->addContact($contact, $first);
         $contactIds[] = $contact->public_id;
         $first = false;
     }
     foreach ($client->contacts as $contact) {
         if (!in_array($contact->public_id, $contactIds)) {
             $contact->delete();
         }
     }
     if (!$publicId || $publicId == '-1') {
         event(new ClientWasCreated($client));
     } else {
         event(new ClientWasUpdated($client));
     }
     return $client;
 }
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:52,代码来源:ClientRepository.php

示例11: getViewModel

 private static function getViewModel()
 {
     // Tax rate $options
     $account = Auth::user()->account;
     $rates = TaxRate::scope()->orderBy('name')->get();
     $options = [];
     $defaultTax = false;
     foreach ($rates as $rate) {
         $options[$rate->rate . ' ' . $rate->name] = $rate->name . ' ' . ($rate->rate + 0) . '%';
         // load default invoice tax
         if ($rate->id == $account->default_tax_rate_id) {
             $defaultTax = $rate;
         }
     }
     return ['entityType' => ENTITY_QUOTE, 'account' => Auth::user()->account, 'products' => Product::scope()->orderBy('id')->get(['product_key', 'notes', 'cost', 'qty']), 'taxRateOptions' => $options, 'defaultTax' => $defaultTax, 'countries' => Cache::get('countries'), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'currencies' => Cache::get('currencies'), 'sizes' => Cache::get('sizes'), 'paymentTerms' => Cache::get('paymentTerms'), 'languages' => Cache::get('languages'), 'industries' => Cache::get('industries'), 'invoiceDesigns' => InvoiceDesign::getDesigns(), 'invoiceFonts' => Cache::get('fonts'), 'invoiceLabels' => Auth::user()->account->getInvoiceLabels(), 'isRecurring' => false];
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:16,代码来源:QuoteController.php

示例12: store

 public function store()
 {
     $data = Input::all();
     $error = $this->clientRepo->getErrors($data);
     if ($error) {
         $headers = Utils::getApiHeaders();
         return Response::make($error, 500, $headers);
     } else {
         $client = $this->clientRepo->save(isset($data['id']) ? $data['id'] : false, $data, false);
         $client = Client::scope($client->public_id)->with('country', 'contacts', 'industry', 'size', 'currency')->first();
         $client = Utils::remapPublicIds([$client]);
         $response = json_encode($client, JSON_PRETTY_PRINT);
         $headers = Utils::getApiHeaders();
         return Response::make($response, 200, $headers);
     }
 }
开发者ID:njmube,项目名称:invoice-ninja,代码行数:16,代码来源:ClientApiController.php

示例13: save

 /**
  * @param array $data
  * @param Invoice|null $invoice
  * @return \App\Models\Invoice|Invoice|mixed
  */
 public function save(array $data, Invoice $invoice = null)
 {
     if (isset($data['client'])) {
         $canSaveClient = false;
         $canViewClient = false;
         $clientPublicId = array_get($data, 'client.public_id') ?: array_get($data, 'client.id');
         if (empty($clientPublicId) || $clientPublicId == '-1') {
             $canSaveClient = Auth::user()->can('create', ENTITY_CLIENT);
         } else {
             $client = Client::scope($clientPublicId)->first();
             $canSaveClient = Auth::user()->can('edit', $client);
             $canViewClient = Auth::user()->can('view', $client);
         }
         if ($canSaveClient) {
             $client = $this->clientRepo->save($data['client']);
         }
         if ($canSaveClient || $canViewClient) {
             $data['client_id'] = $client->id;
         }
     }
     $invoice = $this->invoiceRepo->save($data, $invoice);
     $client = $invoice->client;
     $client->load('contacts');
     $sendInvoiceIds = [];
     foreach ($client->contacts as $contact) {
         if ($contact->send_invoice) {
             $sendInvoiceIds[] = $contact->id;
         }
     }
     // if no contacts are selected auto-select the first to enusre there's an invitation
     if (!count($sendInvoiceIds)) {
         $sendInvoiceIds[] = $client->contacts[0]->id;
     }
     foreach ($client->contacts as $contact) {
         $invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
         if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
             $invitation = Invitation::createNew();
             $invitation->invoice_id = $invoice->id;
             $invitation->contact_id = $contact->id;
             $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
             $invitation->save();
         } elseif (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
             $invitation->delete();
         }
     }
     return $invoice;
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:52,代码来源:InvoiceService.php

示例14: save

 public function save($data)
 {
     $publicId = isset($data['public_id']) ? $data['public_id'] : false;
     if (!$publicId || $publicId == '-1') {
         $client = Client::createNew();
     } else {
         $client = Client::scope($publicId)->with('contacts')->firstOrFail();
     }
     // convert currency code to id
     if (isset($data['currency_code'])) {
         $currencyCode = strtolower($data['currency_code']);
         $currency = Cache::get('currencies')->filter(function ($item) use($currencyCode) {
             return strtolower($item->code) == $currencyCode;
         })->first();
         if ($currency) {
             $data['currency_id'] = $currency->id;
         }
     }
     $client->fill($data);
     $client->save();
     /*
     if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
         return $client;
     }
     */
     $first = true;
     $contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
     $contactIds = [];
     foreach ($contacts as $contact) {
         $contact = $client->addContact($contact, $first);
         $contactIds[] = $contact->public_id;
         $first = false;
     }
     foreach ($client->contacts as $contact) {
         if (!in_array($contact->public_id, $contactIds)) {
             $contact->delete();
         }
     }
     if (!$publicId || $publicId == '-1') {
         event(new ClientWasCreated($client));
     } else {
         event(new ClientWasUpdated($client));
     }
     return $client;
 }
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:45,代码来源:ClientRepository.php

示例15: index

 /**
  * @return \Illuminate\Contracts\View\View
  */
 public function index()
 {
     $user = Auth::user();
     $viewAll = $user->hasPermission('view_all');
     $userId = $user->id;
     $account = $user->account;
     $accountId = $account->id;
     $dashboardRepo = $this->dashboardRepo;
     $metrics = $dashboardRepo->totals($accountId, $userId, $viewAll);
     $paidToDate = $dashboardRepo->paidToDate($accountId, $userId, $viewAll);
     $averageInvoice = $dashboardRepo->averages($accountId, $userId, $viewAll);
     $balances = $dashboardRepo->balances($accountId, $userId, $viewAll);
     $activities = $dashboardRepo->activities($accountId, $userId, $viewAll);
     $pastDue = $dashboardRepo->pastDue($accountId, $userId, $viewAll);
     $upcoming = $dashboardRepo->upcoming($accountId, $userId, $viewAll);
     $payments = $dashboardRepo->payments($accountId, $userId, $viewAll);
     $expenses = $dashboardRepo->expenses($accountId, $userId, $viewAll);
     $tasks = $dashboardRepo->tasks($accountId, $userId, $viewAll);
     // check if the account has quotes
     $hasQuotes = false;
     foreach ([$upcoming, $pastDue] as $data) {
         foreach ($data as $invoice) {
             if ($invoice->invoice_type_id == INVOICE_TYPE_QUOTE) {
                 $hasQuotes = true;
             }
         }
     }
     // check if the account has multiple curencies
     $currencyIds = $account->currency_id ? [$account->currency_id] : [DEFAULT_CURRENCY];
     $data = Client::scope()->withArchived()->distinct()->get(['currency_id'])->toArray();
     array_map(function ($item) use(&$currencyIds) {
         $currencyId = intval($item['currency_id']);
         if ($currencyId && !in_array($currencyId, $currencyIds)) {
             $currencyIds[] = $currencyId;
         }
     }, $data);
     $currencies = [];
     foreach ($currencyIds as $currencyId) {
         $currencies[$currencyId] = Utils::getFromCache($currencyId, 'currencies')->code;
     }
     $data = ['account' => $user->account, 'paidToDate' => $paidToDate, 'balances' => $balances, 'averageInvoice' => $averageInvoice, 'invoicesSent' => $metrics ? $metrics->invoices_sent : 0, 'activeClients' => $metrics ? $metrics->active_clients : 0, 'activities' => $activities, 'pastDue' => $pastDue, 'upcoming' => $upcoming, 'payments' => $payments, 'title' => trans('texts.dashboard'), 'hasQuotes' => $hasQuotes, 'showBreadcrumbs' => false, 'currencies' => $currencies, 'expenses' => $expenses, 'tasks' => $tasks];
     return View::make('dashboard', $data);
 }
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:46,代码来源:DashboardController.php


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