/shredindex-backend

The back-end for www.shredindex.com

Primary LanguagePHP

ShredIndex (Back-end)

The back-end for www.shredindex.com

Getting started

To be added...

Setup

A set of Docker platform is included for running the project.

Preparation

  1. Install Docker https://docs.docker.com/get-docker/
  2. If not installed with Docker Desktop, Docker Compose install https://docs.docker.com/compose/install/
  3. Copy .infrastructre/docker-compose.yml.dist to .infrastructre/docker-compose.yml
  4. Copy .infrastructre/.env.dist to .infrastructre/.env
  5. Copy .infrastructre/etc/nginx/conf.d/default.conf.dist to .infrastructre/etc/nginx/conf.d/default.conf
  6. Copy .env.dist to .env

Optionally, you can make any changes to the resulting .env docker-compose.yml and default.conf to suit your needs.

Up

From .infrastructure/ use

docker-compose up -d

When all docker containers are running, use

docker exec shredindex-backend-php php artisan october:up

Copy the Admin password generated by php artisan october:up, supplied during the terminal output. E.g:

...
- The following password has been automatically generated for the "admin" account: sVHffUkY7BR5F5AngwDCV1

(Note: A new password is generated every time)

Open in browser

If you are using the default preparation: Visit http://localhost:8080/backend

IMPORTANT: Activate our Underflip theme

Visit http://localhost:8080/backend/cms/themes and click "Activate" below the "Underflip" theme.

Activating the theme ensures all pages and menus are made available to the front-end (this also impacts front-end routes).

GraphQL

You can query the GraphQL server at /graphql e.g http://localhost:8080/graphql

An easy way to query the GraphQL server is to use the Chrome GraphiQL extension

Development & Testing

Adding pages

The frontend relies on page-data from the CMS for its routes and views. For this purpose, we use an overly-opinionated combination of October CMS's CMS Page and Rainlab's Static Menu.

Note: We do not use Rainlab's Static Pages.

To add a new page, you can create a CMS page (be sure to make one with no content). Simply follow the out-of-the-box Pages documentation.

Note: Our frontend does not use any page-content from the CMS.

Seed Test Data

Test Data can be seeded with the resorts:seed_test_data artisan command.

The resorts:seed_test_data has the --fresh option to tear down seeded data before re-seeding (e.g php artisan resorts:seed_test_data --fresh)

There's also a handy composer script to run this from your host machine (uses the --fresh option):

composer seed-test-data

Adding seed data

Our Seeders are in plugins/underflip/resorts/database/seeders. Add another Seeder to seed new fixtures for test data. Use the existing Seeders as an example.

To engage a Seeder, add it to the Underflip\Resorts\Console\SeedTestData::$seeders e.g

plugins/underflip/resorts/console/SeedTestData.php:

protected $seeders = [
    ...,
    YourSeeder::class,
];

NOTE: Seeders must be in topological order with dependencies first, so that Seed records exist for subsequent Seeders that depend on them

Seeder::down()

When you want to tear down seeded fixtures with the --fresh option seeds a fresh set of fixtures, make sure that your Seeder implements Downable.

e.g

class MySeeder extents Seeder implements Downable

Each Downable Seeder uses a public function down() method to control the tear down behaviour when the resorts:seed_test_data command's --fresh option is used.

Plugin refresh

When you make any changes to our Resort plugin's migrations or seeders, you can refresh the plugin to re-run the current version using the plugin:refresh Underflip.Resorts artisan command.

There's also a handy composer script to run this from your host machine:

composer plugin-refresh

Total scores ("Total Shred Score")

Total scores are whenever a Resort's rating is created, saved or deleted.

Manually refresh total scores

Manually refresh Resort total scores with the resorts:refresh_total_score artisan command.

There's also a handy composer script to run this from your host machine:

composer resorts-refresh-total-shred-score

Contributors

Thomas Hansen Jackson Darlow