<p align="center">
<img height="30px" src="https://www.eae.pt/images/icons/logo-white.svg"> 
EAST ATLANTIC ENGINEERING
</p>


## Installation (Local, with Lando)
This EAE Base CMS is built on Laravel 8.0, which has 
these [requirements](https://laravel.com/docs/8.0/installation#server-requirements).

1. You need to copy the .env.example to .env . There you have to set the following:

   * **APP_NAME** - Usually the name of the project. If the name has spaces you need to enclose it in quotes
   * **APP_ENV** - Environment you are running the project. If you are running locally put **local**
   * **APP_DEBUG** - Set to true if you what to see the error stack screen
   * **APP_URL** - The base url for your website. It does not finish with trailing slashes (ex:http://eae-base-cms.lndo.site)
   * **DB_*** - Set the appropriate database credentials. The example credential are correct if you are running lando
   * **MAIL_*** Set the appropriate email service credentials. The example is correct if you are running lando and you what to 
send the emails to mailhog
   * **EAE_ADMIN_DEFAULT_PASSWORD** - Set the default admin password when creating the project. This will be used when you run 
the database seeders
   * **EAE_RECAPTCHA_*** - Set the google recaptcha keys. The backoffice is using recapcha v3
   * **EAE_GOOGLE_API_KEY** - Set the google maps javascript api key

2. Run `lando start` (optional if you are not running lando)

3. Run `composer install` or  `lando composer install` (the last one if you are running lando)

4. Run `php artisan key:generate` or `lando artisan key:generate` (the last one if you are running lando) to generate 
the APP_KEY in .env

5. Run `php artisan migrate` or `lando artisan migrate && lando artisan migrate --path="/database/migrations/project"` (the last one if you are running lando)

6. Run `php artisan db:seed` or `lando artisan db:seed` (the last one if you are running lando)
    - When seeding the DB two example menus will be added to the Menus Table. Change/Add/Remove the menus as necessary.

7. Better yet, just run `lando prep-db`

8. Run `lando php artisan storage:link` to create the link for the storage, to be able to access the uploaded media

After this you should be able to access with APP_URL\admin. 
- Username is `admin`
- Password is the one defined in .env as EAE_ADMIN_DEFAULT_PASSWORD 
- If in development environment (lando) you can check the APP URL with `lando info`

## Installation (Staging)

1. Prepare the docker image with the dependencies (PHP7.4, Mysql, etc).

2. Prepare the database, `CREATE DATABASE xpto...`, paying attention to the charset (utf8mb4) and collation (utf8mb4_unicode_ci).

3. Clone the repository to the root of `/var/www/html` (staging or master branch).

4. Prepare the `.env` file with the necessary adaptations. (DB, project url, Admin password (should be set as ENV VAR in production))

5. Run `composer install`.

6. With `su`:
   1. Run `chown eae:www-data -R logs/`, `chown eae:www-data -R app/` and `chown eae:www-data -R framework/`
   2. In `/etc/apache2/sites-enabled` , add (1)`/public` and (2)`/public/` at the end of `...www/html` (2 places)

7. Run `php artisan storage:link`

## Installation (Production)

1. at CloudWays

2. Connect by ssh, go to applications/backoffice/public_html

3. Do whatever you need to do to make this work (git, composer, artisan)
   1. No need for the apache2 configs and permission settings (from staging)

## Important Notes

1. When adding references to images in the seeders, take into consideration that:
   1. When you add the image through Media Manager, some changes are made to the filename (lowcase, slugify, etc)
   2. You have to take the previous point into consideration when setting the filename and original_filename on the table record
