糖CRM/laravel-bean

此包已弃用,不再维护。未建议替代包。

SugarCRM eloquent风格连接器,用于Laravel框架。

维护者

详细信息

github.com/sugarcrm/laravel-bean

安装: 242

依赖: 0

建议者: 0

安全: 0

星标: 6

关注者: 21

分支: 6

此包尚未发布版本,信息有限。


README

SugarCRM Bean基础设施,用于Laravel

使用此工具,可以轻松从Laravel应用程序访问SugarCRM beans

此包目前处于alpha状态,不适合生产使用

待办事项

更新Guzzle到最新版本(5.*)

实现关系

实现缺失的过滤器

测试

以下是一些基本说明,帮助您开始使用此包。

安装

此包旨在通过Composer安装。以下说明假设您已安装并配置了Composer。

配置

您已安装laravel-bean后,需要对其进行配置,以便它可以使用。

生产配置

Laravel-bean通过API与SugarCRM通信,而不是通过直接数据库连接。

元数据缓存

为了您的方便,我们本地存储元数据,因此您需要将新表添加到系统中。

php artisan migrate --package sugarcrm/laravel-bean

用法

Laravel的查询构建器位于Laravel-Bean的根部,因此它的大部分功能和原则都符合该包。

Beans

截至本文撰写时,Laravel-Bean尚未设置为用作真正的查询构建器。您必须设置扩展Laravel-Bean的模型,才能使用查询构建器。

SugarCRM用户模型将类似于以下内容

<?php namespace App\Models\Beans;

use Sugarcrm\Bean\Bean;

class UserBean extends Bean {
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'Users';


}

查询

Laravel-Bean的最终目标是尽可能地将SugarCRM的过滤器和关系API与原生Laravel Eloquent结合。

选择

根据我们的UserBean示例,我们可以查询用户模块


$bean = new UserBean();
$beans = $bean->get(); // get all records in the module. Please keep in mind that hardcoded limit is 1000 records.


您可以设置限制和偏移量

$beans = $bean->take(10)->get(); // get first 10 records in the module

$beans = $bean->take(10)->skip(10)->get(); // get skip first 10 records and get next 10 records in the module

Where子句

由于SugarCRM API的性质,并非所有典型数据库操作都可用。

以下是一个操作类型列表

$equals

在该字段上进行精确匹配。

$bean->where('name', 'something')->get();
$not_equals

匹配非匹配值。

$bean->where('name', '!=', 'something')->get();
$starts

匹配以该值开头的任何内容。

$bean->whereStartsWith('name', 'something')->get();

$bean->where('name', 'starts', 'something')->get();
$ends

匹配以该值结尾的任何内容。

$bean->whereEndsWith('name', 'something')->get();

$bean->where('name', 'ends', 'something')->get();
$contains

匹配包含该值的任何内容。

$bean->where('name', 'like', 'something')->get();
$in

查找字段匹配数组中指定值之一的任何内容。

$bean->whereIn('name', array('Something','Else'))->get();
$not_in

查找字段与指定的数组值不匹配的所有内容。

$bean->whereNotIn('name', array('Something','Else'))->get();
$is_null

检查字段是否为null。此操作不需要指定值。

$bean->whereNull('name')->get();
$not_null

检查字段是否不为null。此操作不需要指定值。

$bean->whereNotNull('name')->get();
$lt

当字段值小于指定值时匹配。

$bean->where('count', '<', 1)->get();
$lte

当字段值小于或等于指定值时匹配。

$bean->where('count', '<=', 1)->get();
$gt

当字段值大于指定值时匹配。

$bean->where('count', '>', 1)->get();
$gte

当字段值大于或等于指定值时匹配。

$bean->where('count', '>=', 1)->get();

插入

更新

删除