Piction API library
This is a package for quick integration with Pictino for storing records in a more usable fashion., (*1)
composer require wearebraid/piction
php artisan vendor:publish --provider="Wearebraid\Piction\PictionServiceProvider"
.env
file:PICTION_HOST=http://<your-host-here>/piction/ PICTION_USERNAME=username PICTION_PASSWORD=password
config/app.php
... 'providers' => [ ... Wearebraid\Piction\PictionServiceProvider::class, ... ], 'aliases' => [ ... 'Piction' => Wearebraid\Piction\Facades\Piction::class, ... ], ...
config/piction.php
host
: This is set to pull from the .env
file to set the host URL for your Piction installuser
: This is set to pull from the .env
file to set the desired user for retrieving data from Pictionpass
: This is set to pull from the .env
file to set the desired user's password for retrieving data from Pictionendpoint
: Default is !soap.jsonget
, you should not need to change this as most of the functionality is relying on JSON data returned from Piction.use_scout
: Default is false
If you choose to use Laravel's Scout set this to true
. More details on using Scout and the Scout Record class below.timeout
: Default is 300
, this is the number of seconds a Piction call will take before Guzzle will timeout.Why use Scout? Because it is AWESOME! Follow the Scout setup. Once you have it configured, in config/piction.php
set 'use_scout' => true
, (*2)
From then on, instead of using Wearebraid\Piction\Models\Record
as your main record model, switch to Wearebraid\Piction\Models\Scout\Record
, (*3)
This model extends the normal record model adding the Searchable
functions for indexing the records for quick searches. Then from within a controller you can then use Record::search('spiders')->paginate(20);
, (*4)
php artisan piction:collections
This is the main script you will run daily Stores latest collection info to database and adds any new collections. These records will also keep track of the last updated time for the collection. Collections that have been removed from Piction will be deleted from the database as well as all records in that collection. This script also:
php artisan piction:records collection_id
This command will connect to Piction and retrieve ALL records since the last run for a spcific collection. A collection id is required to run this script.php artisan piction:deleted
Since Piction doesn't support webhooks, we can get the latest data each day but we don't know what's been deleted. That's where this script comes in. It connects to Piction retrieving a list of all deleted UMO's and then deletes any of those found in the database.