geccomedia / weclapp
Weclapp api via laravel eloquent
Installs: 1 795
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 5
Forks: 2
Open Issues: 2
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^6.2.1|^7.1.0
- illuminate/support: 9.*|10.*
Requires (Dev)
- orchestra/testbench: 7.*|8.*
README
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