This soils platform is the result of a collaboration between the Soils and the Research Methods Support teams, a pair of cross-cutting projects from the Collaborative Crop Research Program (CCRP).
This platform is built using Laravel/PHP. The front-end is written in VueJS and the admin panel uses Backpack for Laravel.
- Clone repo:
git@github.com:stats4sd/ccrp-soils.git
- Copy
.env.example
as a new file and call it.env
- Update variables in
.env
file to match your local environment:- Check APP_URL is correct
- Update DB_DATABASE (name of the local MySQL database to use), DB_USERNAME (local MySQL username) and DB_PASSWORD (local MySQL password)
- If you need to test the Kobo link, make sure QUEUE_CONNECTION is set to
database
orredis
(and that you have redis setup locally). Also add your test KOBO_USERNAME and KOBO_PASSWORD - If you need to test real email sending, update the MAIL_MAILER to mailgun, and copy over the Stats4SD Mailgun keys from 1 Password
- Create a local MySQL database with the same name used in the
.env
file - Run the following setup commands in the root project folder:
composer install
php artisan key:generate
php artisan backpack:install
php artisan telescope:publish
npm install
npm run dev
- Migrate the database:
php aritsan migrate:fresh --seed
or copy from the staging site
To run the local notifications, start up Laravel Websockets locally: php artisan websockets:serve
. This runs the websockets server on localhost port 6001.
To test the job queue locally, run Horizon: php artisan horizon
.
Data download in wide format extracts data in one single sheet in excel file.
It is achieved by extracting data from database view.
There is a "base view" called "samples_merge" for most of the projects.
The CREATE VIEW SQL is stored in a manually created file database\views\samples_merged.sql.
For projects with specific data download requirement, the CREATE VIEW SQL is generated dynamically and executed when project is created or updated.
When there is a new analysis result, update the "base view" SQL in two files:
- database\views\samples_merged.sql
- src\App\Http\Controllers\SampleMergedController.php
Then run artisan command generatedbviews to re-generate database views.
php artisan generatedbviews
Data download in split format extracts data in multiple sheets in excel file.
Individual analysis result table is extracted as individual sheet in excel file.
When there is a new analysis result, add new Export class for new analysis result table, then add the new Export class to SoilWorkbookExport.php.