mralston / iq
Package for working with IQ CRM.
Requires
- illuminate/database: ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Introduction
This package provides a way to work with the IQ Solar database.
Config
This package uses the iq database connection. Add the following to config/database.php:
'iq' => [ 'driver' => 'sqlsrv', 'url' => env('IQ_DATABASE_URL'), 'host' => env('IQ_DB_HOST'), 'port' => env('IQ_DB_PORT', 1433), 'database' => env('IQ_DB_DATABASE'), 'username' => env('IQ_DB_USERNAME'), 'password' => env('IQ_DB_PASSWORD'), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, ],
The database connection can then be set up as follows in the .env file:
IQ_DB_HOST=<IQ SQL Server hostname or IP address> IQ_DB_DATABASE=<IQ SQL Server database> IQ_DB_USERNAME=<IQ SQL Server username> IQ_DB_PASSWORD=<IQ SQL Server password>
Timezone
IQ stores local wall-clock times. Every date the package stamps on a new customer (initial date,
visit, invoice, install note, process action due dates and the notes heading) is taken in
iq.timezone. Leave it null to use the application's timezone; set it when the application runs
in UTC but IQ expects UK time:
IQ_TIMEZONE=Europe/London
Nova
A customer sold from a Nova quote is linked to it by tCustomers.NovaQuoteUuid
(nvarchar(36)), which must be added to IQ before it is used:
$customer = Customer::withCompany($company) ->withRep($rep) // ...the other with* builders ->withNovaQuoteUuid($quote->uuid) ->withAttrs([...]) ->create(); $customer = \Mralston\Iq\Models\Customer::findByNovaQuoteUuid($quote->uuid);
- Without
withNovaQuoteUuid()the column is never written, so IQ databases without it keep working. - With it,
model_idmay be left out: the customer'sImportIdandQuoteIdstay null and thetQuotesrow is written withQuoteId0. Without it, a missingmodel_idstill throwsNoQuoteException. create()writes everything in one transaction on theiqconnection and takes the order and invoice numbers fromtUsunder an update lock, so it is safe to run from queued jobs at once.- The service clears its builder state after every
create(), and the facade resolves a fresh service for each call, so nothing set for one customer reaches the next. - It runs under
Model::shouldBeStrict(). To pass the rep's branch, eager load it ($rep->load('branch')) rather than reading$rep->branchlazily.
Testing
composer install
composer test
The suite runs against in-memory SQLite registered as the iq connection.
Security Vulnerabilities
Please e-mail security vulnerabilities directly to me.
Licence
Package is open-sourced software licenced under the MIT license.
IQ Solar is produced by and remains copyright of Lewis John Limited.