berthott/laravel-sx is a Laravel package for a surveyxact api integration for laravel.
It currently has 0 GitHub stars and 1.245 downloads on Packagist (latest version 3.0.29).
Install it with composer require berthott/laravel-sx.
Discover more Laravel packages by berthott
or browse all Laravel packages to compare alternatives.
Last updated
A SurveyXAct (SX) API Integration for Laravel. Easily add SX integration by adding a Trait.
For a connection between Laravel, it is necessary, to own a SX License. The connection is set up per survey. The user that is used to query data from this survey need to have sufficient access rights within SX. For more information see the Consultant Documentation
$ composer require berthott/laravel-sx
SX is a surveying tool that offers a questionnaire to the end user who will respond which will fill out one row in a database with values corresponding to their answers. This row is referred to as respondent, so the whole dataset will be the respondents. The structure of this respondents table including information question type, as well as the questionnaire which is the labels for the structure, and the labels for all possible answers can be downloaded by SX's API.
In addition, respondents can be created and prefilled with background variables via the API.
For more information see the SX API Documentation.
This package will provide all the API implementation for you. Once you connect a survey, the respondent's data from SX will be synced with your own database. Interacting (creating, editing and deleting respondents) with this package will ensure to always maintain the latest data in both table, SX and our own.
If changes are done to the SX Database by end users a sync can be triggered via the sync route or by the sx:import Artisan command.
A distributable is an entity within your database that can provide background variable to pre-fill respondents data. It corresponds to a sxable and provides some useful routes for collecting respondents.
There's different possible use cases, that are implemented by the ngs-core/sx-entity package.
php artisan make:model YourModelSxable trait to your newly generated model.surveyId() method to provide the SX connection.yourmodels => the entities in wide formatyourmodels_long => the entities in long formatyourmodel_questionsyourmodel_labelsyourmodels/ => get all entitiesyourmodels/{yourmodel} => get respondent information from our DByourmodels/{yourmodel}/show_respondent => get respondent information from inside SXyourmodels/ => create a new respondent inside SX and our DByourmodels/{yourmodel} => update a respondent inside SX and our DByourmodels/{yourmodel} => delete a respondent inside SX and in our DByourmodels/destroy_many => delete a respondent inside SX and in our DByourmodels/sync => sync all respondent answers from SX to our DByourmodels/export => download a XLSX exportyourmodel/structure => get all columns inside SX and their meta informationyourmodel/labels => get all labels for the survey questionsyourmodel/report => get report data for the surveyyourmodel/report_pdf => get a PDF report from some frontend chartsyourmodel/languages => get the SX survey languagesyourmodel/preview => get a collect url for a preview survey\berthott\SX\Models\Traits\Sxable.php artisan make:model YourModelSxDistributable trait to your newly generated model.sxable() method to provide the connection with a Sxable.yourmodels/{yourmodel} => create a new respondent and redirect to its collect URLyourmodels/{yourmodel}/qrcode => get a QR code for the collect endpointyourmodels/{yourmodel}/pdf => download a PDF with the QR codeyourmodels/{yourmodel}/sxdata => get some data that can be used inside SX surveysyourmodels/{yourmodel}/preview => get a collect url for a preview survey\berthott\SX\Models\Traits\SxDistributable.To change the default options use
$ php artisan vendor:publish --provider="berthott\SX\SxServiceProvider" --tag="config"
namespace: String or array with one ore multiple namespaces that should be monitored for the configured trait. Defaults to App\Models.namespace_mode: Defines the search mode for the namespaces. ClassFinder::STANDARD_MODE will only find the exact matching namespace, ClassFinder::RECURSIVE_MODE will find all subnamespaces. Defaults to ClassFinder::STANDARD_MODE.prefix: Defines the route prefix. Defaults to api.middleware: An array of all middlewares to be applied to all of the generated routes. Defaults to [].auth: Defines the SX Basic Auth. Defaults to env variables SX_USERNAME and SX_PASSWORD.defaultUnique: An array of unique columns inside the SX database. Can be extended per entity with \berthott\SX\Models\Traits\Sxable::uniqueFields(). Defaults to ['respondentid'].primary: Defines the primary column inside the SX database. Defaults to SXs internal ID respondentid.filters: Defines an array of prefixes that will be filtered during SX import automatically. Defaults to ['x_'].api: Defines the a JSON representation of the SX API. See the SX API Documentation.exportFormat: Defines the export format. Possible values are: XLSX, CSV, TSV, ODS, XLS, HTML, MPDF, DOMPDF, TCPDF. See the Laravel-Excel Documentation. Defaults to XLSX.excludeFromExport: Defines an array of columns to be excluded from the export. Defaults to ['created_at', 'updated_at', 'survey', 'respondentid'].SX uses short variable names for export by default. While the SX API gives us the option to export also long names, when interacting with respondents, it requires short names. Therefore we export the short names and use the returned structure to guess the short and full names however we need them. See \berthott\SX\Services\SxSurveyService.
Sxable, Distributable).SxApiService and is separated into different endpoint with SxHttpService. As API definition might change in the future it is configurable inside the api config.SxSurveyService is an interface into the SX survey data. It caches some data. SxRespondentService is an interface for interacting with respondents. Both utilize SxHttpService for this.Sxable
SxSurveyServiceSxableController
SxRespondentService for creating respondents in SXSxableObserverSxable::doUpsert)Distributable
DistributableController
SxReportRequest adds some functionality around filtering and aggregationRespondentsImported will be fired whenever new entities were imported. Useful for flushing the cacheTested with Laravel 10.x.
See License File. Copyright © 2023 Jan Bladt.