本文整理汇总了PHP中app\models\Invoice::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::save方法的具体用法?PHP Invoice::save怎么用?PHP Invoice::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Invoice
的用法示例。
在下文中一共展示了Invoice::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
try {
$admin = \Auth::User();
if (!$admin) {
return $this->failResponse('admin not logged in');
}
$invoiceObj = new Invoice();
$data = $this->getRequestBody();
$invoiceObj->customer_id = $data['customer_id'];
$invoiceObj->attn = $data['attn'];
$invoiceObj->invoice_number = $data['invoice_number'];
$invoiceObj->description = $data['description'];
$invoiceObj->save();
if (!$invoiceObj->save()) {
Log::error("error in saving");
$errors = $invoiceObj->getErrors();
return $this->failResponse('Validation failed. Cannot save data.' . $errors);
} else {
return $this->successResponse('updated sucessfully');
}
} catch (\Exception $e) {
Log::error($invoiceObj->getErrors());
return $this->failResponse($e->getMessage());
}
}
示例2: create
public function create($id)
{
$invoice = new Invoice();
$invoice->customer_id = $id;
$invoice->save();
return redirect("/invoice/" . $invoice->getId());
}
示例3: sendInvoice
public function sendInvoice(Invoice $invoice)
{
$invoice->load('invitations', 'client', 'account');
$entityType = $invoice->getEntityType();
$view = 'invoice';
$subject = trans("texts.{$entityType}_subject", ['invoice' => $invoice->invoice_number, 'account' => $invoice->account->getDisplayName()]);
$accountName = $invoice->account->getDisplayName();
$emailTemplate = $invoice->account->getEmailTemplate($entityType);
$invoiceAmount = Utils::formatMoney($invoice->getRequestedAmount(), $invoice->client->currency_id);
foreach ($invoice->invitations as $invitation) {
if (!$invitation->user || !$invitation->user->email) {
return false;
}
if (!$invitation->contact || !$invitation->contact->email) {
return false;
}
$invitation->sent_date = \Carbon::now()->toDateTimeString();
$invitation->save();
$variables = ['$footer' => $invoice->account->getEmailFooter(), '$link' => $invitation->getLink(), '$client' => $invoice->client->getDisplayName(), '$account' => $accountName, '$contact' => $invitation->contact->getDisplayName(), '$amount' => $invoiceAmount];
$data['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate);
$data['link'] = $invitation->getLink();
$data['entityType'] = $entityType;
$data['invoice_id'] = $invoice->id;
$fromEmail = $invitation->user->email;
$this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data);
Activity::emailInvoice($invitation);
}
if (!$invoice->isSent()) {
$invoice->invoice_status_id = INVOICE_STATUS_SENT;
$invoice->save();
}
Event::fire(new InvoiceSent($invoice));
}
示例4: actionCreate
/**
* Creates a new Invoice model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Invoice();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例5: actionCreate
public function actionCreate()
{
$model = new Invoice(['user_name' => Yii::$app->user->identity->name, 'status' => 'create']);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例6: actionCreate
/**
* Creates a new Registration model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$registration_model = new Registration();
$registration_model->registration_type_id = 1;
$invoice_model = new Invoice();
if ($registration_model->load(Yii::$app->request->post())) {
$registration_model->file_payment_receipt = UploadedFile::getInstance($registration_model, 'file_payment_receipt');
switch ($registration_model->registration_type_id) {
case 2:
case 4:
case 5:
$registration_model->file_student_id = UploadedFile::getInstance($registration_model, 'file_student_id');
break;
}
$isValid = $registration_model->validate();
if ($registration_model->requires_invoice) {
if ($invoice_model->load(Yii::$app->request->post())) {
$isValid = $isValid && $invoice_model->validate();
var_dump($invoice_model->errors);
}
}
var_dump($registration_model->errors);
if ($isValid) {
if ($registration_model->save(false)) {
if ($registration_model->requires_invoice) {
$invoice_model->registration_id = $registration_model->id;
if ($invoice_model->save(false)) {
return $this->redirect(['view', 'id' => $registration_model->id]);
}
} else {
return $this->redirect(['view', 'id' => $registration_model->id]);
}
}
}
} else {
return $this->render('create', ['registration_model' => $registration_model, 'invoice_model' => $invoice_model]);
}
}
示例7: createNinjaInvoice
public function createNinjaInvoice($client)
{
$account = $this->getNinjaAccount();
$lastInvoice = Invoice::withTrashed()->whereAccountId($account->id)->orderBy('public_id', 'DESC')->first();
$publicId = $lastInvoice ? $lastInvoice->public_id + 1 : 1;
$invoice = new Invoice();
$invoice->account_id = $account->id;
$invoice->user_id = $account->users()->first()->id;
$invoice->public_id = $publicId;
$invoice->client_id = $client->id;
$invoice->invoice_number = $account->getNextInvoiceNumber();
$invoice->invoice_date = date_create()->format('Y-m-d');
$invoice->amount = PRO_PLAN_PRICE;
$invoice->balance = PRO_PLAN_PRICE;
$invoice->save();
$item = new InvoiceItem();
$item->account_id = $account->id;
$item->user_id = $account->users()->first()->id;
$item->public_id = $publicId;
$item->qty = 1;
$item->cost = PRO_PLAN_PRICE;
$item->notes = trans('texts.pro_plan_description');
$item->product_key = trans('texts.pro_plan_product');
$invoice->invoice_items()->save($item);
$invitation = new Invitation();
$invitation->account_id = $account->id;
$invitation->user_id = $account->users()->first()->id;
$invitation->public_id = $publicId;
$invitation->invoice_id = $invoice->id;
$invitation->contact_id = $client->contacts()->first()->id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invitation->save();
return $invitation;
}
示例8: setStatusInvoice
public function setStatusInvoice(Invoice $invoice, $status)
{
$invoice->status = $status;
$invoice->save();
return $invoice;
}