sylvester / quickbooks
QuickBooks桌面与Laravel应用程序集成
1.9.0
2023-06-14 12:00 UTC
README
按照以下说明,将此包集成并用于您的Laravel项目。
安装
需要QuickBooks PHP开发工具包(QuickBooks集成支持)
composer require "consolibyte/quickbooks:dev-master"
然后使用以下命令安装此包:
composer require sylvester/quickbooks
接下来,将以下内容添加到您的.env文件中:
QB_DSN=
QB_USERNAME=quickbooks
QB_PASSWORD=password
QB_TIMEZONE=America/New_York
QB_LOGLEVEL=QUICKBOOKS_LOG_DEVELOP
QB_MEMLIMIT=512M
QB_SOAPSERVER=QUICKBOOKS_SOAPSERVER_BUILTIN
QB_QUICKBOOKS_CONFIG_LAST=last
QB_QUICKBOOKS_CONFIG_CURR=curr
QB_QUICKBOOKS_MAX_RETURNED=100
QB_PRIORITY_ITEM=0
QB_QUICKBOOKS_MAILTO=support@onehealthng.com
注意:您的.env文件中的数据库连接需要设置。
在Config/app的providers下添加以下内容:
Sylvester\Quickbooks\Providers\QuickbookdProvider::class
之后,运行以下命令:
php artisan vendor:publish --tag=config
然后访问以下URL以查看是否工作。
https://yourappurl/qbd-webconnector/qbwc
用法
按照以下应用说明,在项目中使用此包。
1. 添加新库存
为了使用此包在QuickBooks中添加新库存,您的示例控制器如下所示:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
// require the package
use Sylvester\Quickbooks\Quickbooksd;
class Additemcontroller extends Controller
{
// make this a protected variable
protected $QBD;
//implement a construct
public function __construct()
{
$this->QBD = new Quickbooksd;
$this->QBD->connect();
}
//saving item to database function
public function saveitem(Request $request){
// below you queue the id of each item so that quickbooks webconnector can pick it up.
$this->QBD->enqueue(QUICKBOOKS_ADD_INVENTORYITEM, $request->input('id'));
}
}
2. 添加新客户
为了使用此包在QuickBooks中添加新客户,您的示例控制器如下所示:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
// require the package
use Sylvester\Quickbooks\Quickbooksd;
class Customercontroller extends Controller
{
// make this a protected variable
protected $QBD;
//implement a construct
public function __construct()
{
$this->QBD = new Quickbooksd;
$this->QBD->connect();
}
//saving customer to database function
public function savecustomer(Request $request){
// below you queue the id of each customer so that quickbooks webconnector can pick it up.
$this->QBD->enqueue(QUICKBOOKS_ADD_CUSTOMER, $request->input('id'));
}
}
3. 添加新销售
为了使用此包在QuickBooks中添加新销售,您的示例控制器如下所示:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
// require the package
use Sylvester\Quickbooks\Quickbooksd;
class Salescontroller extends Controller
{
// make this a protected variable
protected $QBD;
//implement a construct
public function __construct()
{
$this->QBD = new Quickbooksd;
$this->QBD->connect();
}
/saving sales to database function
public function savesales(Request $request){
// below you queue the id of each orders from the orders table not batch_id so that quickbooks webconnector can pick it up.
$this->QBD->enqueue(QUICKBOOKS_ADD_SALESORDER, $request->input('id'));
}
}