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


PHP models\Invitation类代码示例

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


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

示例1: save

 public function save($data)
 {
     if (isset($data['client'])) {
         $client = $this->clientRepo->save($data['client']);
         $data['client_id'] = $client->id;
     }
     $invoice = $this->invoiceRepo->save($data);
     $client = $invoice->client;
     $client->load('contacts');
     $sendInvoiceIds = [];
     foreach ($client->contacts as $contact) {
         if ($contact->send_invoice || count($client->contacts) == 1) {
             $sendInvoiceIds[] = $contact->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:lingxuan630,项目名称:invoiceninja,代码行数:29,代码来源:InvoiceService.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('invitations')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 50; $i++) {
         Invitation::create(['title' => $faker->sentence(6), 'address' => $faker->slug(), 'latitude' => $faker->latitude, 'longitude' => $faker->longitude, 'phone' => $faker->phoneNumber, 'level' => $faker->randomElement(['Mới biết chơi', 'Khá - Giỏi', 'Chuyên nghiệp']), 'time' => $faker->randomElement(['5-7', '7-9', '6-8']), 'description' => $faker->paragraph(4), 'user_id' => $faker->randomElement(range(1, 30))]);
     }
 }
开发者ID:byhbt,项目名称:laravel-skeleton,代码行数:13,代码来源:InvitationTableSeeder.php

示例3: sanitize

 public function sanitize()
 {
     $input = $this->all();
     $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $this->invitation_key)->firstOrFail();
     $input['invitation'] = $invitation;
     $input['gateway_type'] = session($invitation->id . 'gateway_type');
     $this->replace($input);
     return $this->all();
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:9,代码来源:CreateOnlinePaymentRequest.php

示例4: getInvitation

 protected function getInvitation($key)
 {
     $invitation = Invitation::withTrashed()->where('invitation_key', '=', $key)->first();
     if ($invitation && !$invitation->is_deleted) {
         return $invitation;
     } else {
         return null;
     }
 }
开发者ID:hannenijhuis,项目名称:invoiceninja,代码行数:9,代码来源:Authenticate.php

示例5: markBounced

 public function markBounced($messageId, $error)
 {
     $invitation = Invitation::with('user', 'invoice', 'contact')->whereMessageId($messageId)->first();
     if (!$invitation) {
         return false;
     }
     $invitation->email_error = $error;
     $invitation->save();
     $this->userMailer->sendEmailBounced($invitation);
     return true;
 }
开发者ID:magicians,项目名称:invoiceninja,代码行数:11,代码来源:EmailService.php

示例6: getCredentials

 /**
  * 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;
     $invitation_key = session('invitation_key');
     if ($invitation_key) {
         $invitation = Invitation::where('invitation_key', '=', $invitation_key)->first();
         if ($invitation && !$invitation->is_deleted) {
             $credentials['id'] = $invitation->contact_id;
         }
     }
     return $credentials;
 }
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:19,代码来源:AuthController.php

示例7: 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 || count($client->contacts) == 1) {
             $sendInvoiceIds[] = $contact->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:rafaelsisweb,项目名称:invoice-ninja,代码行数:48,代码来源:InvoiceService.php

示例8: create

 public function create()
 {
     $this->validateRoute();
     $user = $this->getRepository()->createOrUpdate($this->request->all());
     $sandboxData = [];
     if (env('APP_ENV') == 'local') {
         $sandboxData['token_email'] = $user->getVerifyEmailToken();
     }
     $invitation = Invitation::where('email', $user->email)->get();
     foreach ($invitation as $item) {
         if (array_key_exists('_id', $item->project)) {
             $application = Application::find($item->project['_id']);
             if (!$application->getUser($user->email)) {
                 $application->setUser(['user_id' => (string) $user->_id, 'role' => $item->role, 'scope' => $item->scope])->save();
             }
         }
     }
     return $this->response->json($user->toArray(), Response::HTTP_CREATED, [], [], $sandboxData);
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:19,代码来源:UsersController.php

示例9: save

 public function save($data, $checkSubPermissions = false)
 {
     if (isset($data['client'])) {
         $can_save_client = !$checkSubPermissions;
         if (!$can_save_client) {
             if (empty($data['client']['public_id']) || $data['client']['public_id'] == '-1') {
                 $can_save_client = Client::canCreate();
             } else {
                 $can_save_client = Client::wherePublicId($data['client']['public_id'])->first()->canEdit();
             }
         }
         if ($can_save_client) {
             $client = $this->clientRepo->save($data['client']);
             $data['client_id'] = $client->id;
         }
     }
     $invoice = $this->invoiceRepo->save($data, $checkSubPermissions);
     $client = $invoice->client;
     $client->load('contacts');
     $sendInvoiceIds = [];
     foreach ($client->contacts as $contact) {
         if ($contact->send_invoice || count($client->contacts) == 1) {
             $sendInvoiceIds[] = $contact->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:sseshachala,项目名称:invoiceninja,代码行数:39,代码来源:InvoiceService.php

示例10: store

 /**
  * @SWG\Post(
  *   path="/invoices",
  *   tags={"invoice"},
  *   summary="Create an invoice",
  *   @SWG\Parameter(
  *     in="body",
  *     name="body",
  *     @SWG\Schema(ref="#/definitions/Invoice")
  *   ),
  *   @SWG\Response(
  *     response=200,
  *     description="New invoice",
  *      @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
  *   ),
  *   @SWG\Response(
  *     response="default",
  *     description="an ""unexpected"" error"
  *   )
  * )
  */
 public function store(CreateInvoiceRequest $request)
 {
     $data = Input::all();
     $error = null;
     if (isset($data['email'])) {
         $email = $data['email'];
         $client = Client::scope()->whereHas('contacts', function ($query) use($email) {
             $query->where('email', '=', $email);
         })->first();
         if (!$client) {
             $validator = Validator::make(['email' => $email], ['email' => 'email']);
             if ($validator->fails()) {
                 $messages = $validator->messages();
                 return $messages->first();
             }
             $clientData = ['contact' => ['email' => $email]];
             foreach (['name', 'private_notes'] as $field) {
                 if (isset($data[$field])) {
                     $clientData[$field] = $data[$field];
                 }
             }
             foreach (['first_name', 'last_name'] as $field) {
                 if (isset($data[$field])) {
                     $clientData[$field] = $data[$field];
                 }
             }
             $client = $this->clientRepo->save($clientData);
         }
     } else {
         if (isset($data['client_id'])) {
             $client = Client::scope($data['client_id'])->firstOrFail();
         }
     }
     $data = self::prepareData($data, $client);
     $data['client_id'] = $client->id;
     $invoice = $this->invoiceRepo->save($data);
     if (!isset($data['id'])) {
         $invitation = Invitation::createNew();
         $invitation->invoice_id = $invoice->id;
         $invitation->contact_id = $client->contacts[0]->id;
         $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
         $invitation->save();
     }
     if (isset($data['email_invoice']) && $data['email_invoice']) {
         $this->mailer->sendInvoice($invoice);
     }
     $invoice = Invoice::scope($invoice->public_id)->with('client', 'invoice_items', 'invitations')->first();
     $transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
     $data = $this->createItem($invoice, $transformer, 'invoice');
     return $this->response($data);
 }
开发者ID:j-beere,项目名称:invoiceninja,代码行数:72,代码来源:InvoiceApiController.php

示例11: saveInvoice

 private function saveInvoice($publicId, $input, $entityType)
 {
     $invoice = $input->invoice;
     $this->taxRateRepo->save($input->tax_rates);
     $clientData = (array) $invoice->client;
     $client = $this->clientRepo->save($invoice->client->public_id, $clientData);
     $invoiceData = (array) $invoice;
     $invoiceData['client_id'] = $client->id;
     $invoice = $this->invoiceRepo->save($publicId, $invoiceData, $entityType);
     $account = Auth::user()->account;
     if ($account->invoice_taxes != $input->invoice_taxes || $account->invoice_item_taxes != $input->invoice_item_taxes || $account->invoice_design_id != $input->invoice->invoice_design_id || $account->show_item_taxes != $input->show_item_taxes) {
         $account->invoice_taxes = $input->invoice_taxes;
         $account->invoice_item_taxes = $input->invoice_item_taxes;
         $account->invoice_design_id = $input->invoice->invoice_design_id;
         $account->show_item_taxes = $input->show_item_taxes;
         $account->save();
     }
     $client->load('contacts');
     $sendInvoiceIds = [];
     foreach ($client->contacts as $contact) {
         if ($contact->send_invoice || count($client->contacts) == 1) {
             $sendInvoiceIds[] = $contact->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:nafrente,项目名称:invoice-ninja,代码行数:38,代码来源:InvoiceController.php

示例12: cloneInvoice

 public function cloneInvoice($invoice, $quotePublicId = null)
 {
     $invoice->load('invitations', 'invoice_items');
     $account = $invoice->account;
     $clone = Invoice::createNew($invoice);
     $clone->balance = $invoice->amount;
     // if the invoice prefix is diff than quote prefix, use the same number for the invoice
     if (($account->invoice_number_prefix || $account->quote_number_prefix) && $account->invoice_number_prefix != $account->quote_number_prefix && $account->share_counter) {
         $invoiceNumber = $invoice->invoice_number;
         if ($account->quote_number_prefix && strpos($invoiceNumber, $account->quote_number_prefix) === 0) {
             $invoiceNumber = substr($invoiceNumber, strlen($account->quote_number_prefix));
         }
         $clone->invoice_number = $account->invoice_number_prefix . $invoiceNumber;
     } else {
         $clone->invoice_number = $account->getNextInvoiceNumber();
     }
     foreach (['client_id', 'discount', 'is_amount_discount', 'invoice_date', 'po_number', 'due_date', 'is_recurring', 'frequency_id', 'start_date', 'end_date', 'terms', 'invoice_footer', 'public_notes', 'invoice_design_id', 'tax_name', 'tax_rate', 'amount', 'is_quote', 'custom_value1', 'custom_value2', 'custom_taxes1', 'custom_taxes2', 'partial'] as $field) {
         $clone->{$field} = $invoice->{$field};
     }
     if ($quotePublicId) {
         $clone->is_quote = false;
         $clone->quote_id = $quotePublicId;
     }
     $clone->save();
     if ($quotePublicId) {
         $invoice->quote_invoice_id = $clone->public_id;
         $invoice->save();
     }
     foreach ($invoice->invoice_items as $item) {
         $cloneItem = InvoiceItem::createNew($invoice);
         foreach (['product_id', 'product_key', 'notes', 'cost', 'qty', 'tax_name', 'tax_rate'] as $field) {
             $cloneItem->{$field} = $item->{$field};
         }
         $clone->invoice_items()->save($cloneItem);
     }
     foreach ($invoice->invitations as $invitation) {
         $cloneInvitation = Invitation::createNew($invoice);
         $cloneInvitation->contact_id = $invitation->contact_id;
         $cloneInvitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
         $clone->invitations()->save($cloneInvitation);
     }
     return $clone;
 }
开发者ID:ricoa,项目名称:invoice-ninja,代码行数:43,代码来源:InvoiceRepository.php

示例13: getInvitation

 private function getInvitation()
 {
     $invitationKey = session('invitation_key');
     if (!$invitationKey) {
         return false;
     }
     $invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
     if (!$invitation || $invitation->is_deleted) {
         return false;
     }
     $invoice = $invitation->invoice;
     if (!$invoice || $invoice->is_deleted) {
         return false;
     }
     return $invitation;
 }
开发者ID:jroblesc,项目名称:invoiceninja,代码行数:16,代码来源:PublicClientController.php

示例14: boot

 /**
  * Bootstrap any necessary services.
  *
  * @return void
  */
 public function boot()
 {
     Table::observe(new TableObserver());
     User::observe(new UserObserver());
     Invitation::observe(new InvitationsObserver());
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:11,代码来源:ObserverServiceProvider.php

示例15: showResetForm

 /**
  * Display the password reset view for the given token.
  *
  * If no token is present, display the link request form.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  string|null $key
  * @param  string|null $token
  * @return \Illuminate\Http\Response
  */
 public function showResetForm(Request $request, $key = null, $token = null)
 {
     if (is_null($token)) {
         return $this->getEmail();
     }
     $data = compact('token');
     if ($key) {
         $contact = Contact::where('contact_key', '=', $key)->first();
         if ($contact && !$contact->is_deleted) {
             $account = $contact->account;
             $data['contact_key'] = $contact->contact_key;
         } else {
             // Maybe it's an invitation key
             $invitation = Invitation::where('invitation_key', '=', $key)->first();
             if ($invitation && !$invitation->is_deleted) {
                 $account = $invitation->account;
                 $data['contact_key'] = $invitation->contact->contact_key;
             }
         }
         if (!empty($account)) {
             $data['account'] = $account;
             $data['clientFontUrl'] = $account->getFontsUrl();
         } else {
             return \Redirect::to('/client/sessionexpired');
         }
     }
     return view('clientauth.reset')->with($data);
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:38,代码来源:PasswordController.php


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