raynl / bizzcloud-laravel
Bizzcloud for Laravel
Requires
- darkaonline/ripcord: ^0.1.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-15 17:44:20 UTC
README
设置
使用composer在您的Laravel项目中安装此包
composer require raynl/bizzcloud-laravel
环境变量
安装包后,您需要设置以下环境变量
BIZZ_URL
服务器URL是实例的域名(例如 https://mycompany.bizzcloud.nl)。
BIZZ_DB
数据库名称是实例的名称(例如 mycompany)
BIZZ_USERNAME
您可以使用具有足够权限访问不同文档的现有用户或创建新用户。
BIZZ_PASSWORD
用户的密码。
以下是一个示例
BIZZ_URL="https://example.bizzcloud.nl/xmlrpc/2"
BIZZ_DB="example"
BIZZ_USERNAME="example@example.nl"
BIZZ_PASSWORD="Password
发布配置
如果您想编辑配置文件,可以发布它。
php artisan vendor:publish --provider="Raynl\Bizzcloud\BizzcloudServiceProvider" --tag="config
工作原理
您创建一个新的Bizzcloud实例。
$bizzcloud = new Bizzcloud();
之后,您可以使用不同的方法。
可用方法
列出记录
可以通过search()进行搜索和过滤来列出记录。
search()需要一个必须的域名过滤器(可能为空),并返回与过滤器匹配的所有记录的数据库标识符。例如,列出客户公司。
如果需要分页,请添加$offset和$limit。
search(string $model, array $search, int $offset = null, int $limit = null): array
计数记录
而不是检索可能非常大的记录列表并计数,可以使用searchCount()检索仅匹配查询的记录数。它接受与search()相同的域名过滤器,没有其他参数。
如果需要分页,请添加$offset和$limit。
searchCount(string $model, array $search, int $offset = null, int $limit = null): array
读取记录
记录数据可以通过read()方法访问,该方法接受由search()返回的id列表(可选)以及要检索的字段列表。默认情况下,它将检索当前用户可以读取的所有字段,这通常是一个非常大的数量。
read(string $model, array $ids, array $parameters_keyword = []): array
列出记录字段
可以使用getFields()来检查模型字段并查看哪些字段似乎很有趣。
因为它返回大量元信息(它也被客户端程序使用),所以在打印之前应该进行过滤。对人类用户最有兴趣的是字符串(字段的标签)、帮助(如果有帮助文本)和类型(以了解期望哪些值,或在更新记录时发送哪些值)
getFields(string $model, array $attributes = ['string', 'help', 'type']): array
搜索和读取
因为这是一个非常常见的任务,所以BizzCloud提供了一个searchAndRead()快捷方式,正如其名称所暗示的那样,它等同于search()后跟read(),但避免了执行两次请求并保留id的需求。
它的参数与search()类似,但它还可以接受一个字段列表(如read(),如果未提供该列表,它将检索匹配记录的所有字段)
searchAndRead(string $model, array $search, array $parameters_keyword = []): array
创建记录
使用create()创建模型的记录。该方法将创建单个记录并返回其数据库标识符。
create()接受一个字段到值的映射,用于初始化记录。对于任何具有默认值且未通过映射参数设置的字段,将使用默认值。
create(string $model, $values): array
更新记录
可以使用update()函数更新记录,它需要一个要更新的记录列表和一个类似于create()的更新字段到值的映射。
可以同时更新多个记录,但它们将被设置为相同的字段值。目前无法执行“计算”更新(设置的值取决于记录的现有值)。
- 日期、日期时间和二进制字段使用字符串值。
update(string $model, int $id, array $values): array
删除记录
可以通过提供它们的ID来批量删除记录。
delete(string $model, array $ids): array
产品
如果您有产品,有一个仅针对产品的类。
$bizzcloud_products = new Products();
有两种方法可用。
获取所有产品
获取所有产品。它使用模型 product.template。
getAllProducts(array $parameters_keyword = []): array
获取指定字段
getAllProducts(['fields' => ['field1', 'field2']]): array
获取偏移量和限制
getAllProducts(['offset' => 0, 'limit' => 10]): array
获取指定字段、偏移量和限制
getAllProducts(['offset' => 0, 'limit' => 10, 'fields' => ['field', 'field']]): array
获取特定ID的产品
获取特定ID的产品。它使用模型 product.template。
getProduct(int $id): array