geccomedia/weclapp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

geccomedia/weclapp

最新稳定版本:v5.0.1

Composer 安装命令:

composer require geccomedia/weclapp

包简介

Weclapp api via laravel eloquent

README 文档

README

Latest Stable Version Total Downloads License

This repo implements most of the Laravel Eloquent Model for the Weclapp web api.

Installation Informations

Require this package with Composer

composer require geccomedia/weclapp

Add the variables to your .env

WECLAPP_BASE_URL=https://#your-sub-domain#.weclapp.com/webapp/api/v1/
WECLAPP_API_KEY=your-key

Usage

Use existing models from "Geccomedia\Weclapp\Models"-Namespace.

Most Eloquent methods are implemented within the limitations of the web api.

<?php

use Geccomedia\Weclapp\Models\Customer;

class YourClass
{
    public function yourFunction()
    {
        $customer = Customer::where('company', 'Your Company Name')
            ->firstOrFail();

Custom models

Example:

<?php namespace Your\Custom\Namespace;

use Geccomedia\Weclapp\Model;

class CustomModel extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'custom-api-route';
}

Mass assignments

If you want to do mass assignment please use unguard and reguard

Example:

$customer = new \Geccomedia\Weclapp\Models\Customer();
\Geccomedia\Weclapp\Models\Customer::unguard();
$customer->fill(['partyType' => 'ORGANIZATION']);
\Geccomedia\Weclapp\Models\Customer::reguard();

Sub Entities

Weclapp api has some models it views as sub entities to other entities. For those cases we need to supply the main entity for the query with whereEntity($name, $id)

Example:

$comments = Comment::whereEntity('customer', 123)->orderByDesc()->get();

Without the call to "whereEntity" the api would complain that we are missing fields. See #22 for more information.

Logging

If you want to see the requests being made, you can use the Connections log

Example:

use Geccomedia\Weclapp\Connection;

app(Connection::class)->enableQueryLog();

\Geccomedia\Weclapp\Models\Customer::create(['name' => 'Test'])

app(Connection::class)->getQueryLog();

License & Copyright

Copyright (c) 2017 Gecco Media GmbH

License

统计信息

  • 总下载量: 2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-14