Skip to content

Commit

Permalink
updated readme, added migration and language files
Browse files Browse the repository at this point in the history
  • Loading branch information
bidi committed Apr 30, 2020
1 parent febce97 commit ca1d5b8
Show file tree
Hide file tree
Showing 9 changed files with 2,039 additions and 4 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ Just like for `II Installing DotKernel frontend using composer` (see above), the
```bash
php vendor/bin/phinx migrate --config="config/migrations.php"
```
- [Get a recaptcha key pair](https://www.google.com/recaptcha/admin) and add them in `config/autoload/local.php`
- If you use `composer create-project`, the project will go into development mode automatically after installing. The development mode status can be checked and toggled by using these composer commands
```bash
Expand All @@ -113,6 +112,25 @@ This will enable dev mode by turning debug flag to `true` and turning configurat
> Charset recommendation: utf8mb4_general_ci
## NPM Commands
To install dependencies into the `node_modules` directory run this command.
```bash
npm install
```
The watch command compiles the components then watches the files and recompiles when one of them changes.
```bash
npm run watch
```
After all updates are done, this command compiles the assets locally, minifies them and makes them ready for production.
```bash
npm run prod
```
## Testing (Running)
Note: **Do not enable dev mode in production**
Expand Down
4 changes: 1 addition & 3 deletions data/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
cache
110 changes: 110 additions & 0 deletions data/database/migrations/20200416084037_default_schema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php

use Phinx\Migration\AbstractMigration;
use Frontend\User\Entity\User;
use Frontend\User\Entity\UserResetPassword;

class DefaultSchema extends AbstractMigration
{
protected array $fkCascade = ['delete' => 'CASCADE', 'update' => 'CASCADE'];

/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->table('user', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci'])
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('identity', 'string', ['null' => false, 'limit' => 100])
->addColumn('password', 'string', ['null' => false, 'limit' => 100])
->addColumn('status', 'enum',
[
'default' => User::STATUS_PENDING,
'values' => User::STATUSES
]
)
->addColumn('isDeleted', 'enum',
[
'default' => User::IS_DELETED_NO,
'values' => [User::IS_DELETED_YES, User::IS_DELETED_NO]
]
)
->addColumn('hash', 'string', ['null' => false, 'limit' => 100])
->addTimestamps('created', 'updated')
->addIndex(['identity'], ['name' => 'identity', 'unique' => true])
->create();

$this->table('user_detail', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci'])
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('userUuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('firstName', 'string', ['null' => true, 'limit' => 255])
->addColumn('lastName', 'string', ['null' => true, 'limit' => 255])
->addTimestamps('created', 'updated')
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade)
->create();

$this->table('user_avatar', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci'])
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('userUuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('name', 'string', ['null' => false, 'limit' => 255])
->addTimestamps('created', 'updated')
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade)
->create();

$this->table('user_role', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci'])
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('name', 'string', ['null' => false, 'limit' => 150])
->addTimestamps('created', 'updated')
->addIndex(['name'], ['name' => 'name', 'unique' => true])
->create();

$this->table('user_roles', ['id' => false, 'primary_key' => ['userUuid', 'roleUuid']])
->addColumn('userUuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('roleUuid', 'binary', ['null' => false, 'limit' => 16])
->addTimestamps('created', 'updated')
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade)
->addForeignKey('roleUuid', 'user_role', 'uuid', $this->fkCascade)
->create();

$this->table('user_reset_password', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci'])
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16])
->addColumn('userUuid', 'binary', ['null' => true, 'limit' => 16])
->addColumn('hash', 'string', ['null' => false, 'limit' => 100])
->addColumn(
'status',
'enum', [
'null' => false,
'default' => UserResetPassword::STATUS_REQUESTED,
'values' => UserResetPassword::STATUSES
]
)
->addColumn('expires', 'timestamp', ['null' => true])
->addTimestamps('created', 'updated')
->addIndex(['userUuid'], ['unique' => false])
->addIndex(['hash'], ['unique' => true])
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade)
->create();
}
}
56 changes: 56 additions & 0 deletions data/database/migrations/20200416154725_contact_message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

use Phinx\Migration\AbstractMigration;

class ContactMessage extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->table('contact_message', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci'])
->addColumn('uuid', 'binary', ['limit' => 16])
->addColumn('email', 'string', ['limit' => 150])
->addColumn('name', 'string', ['limit' => 150])
->addColumn('subject', 'text')
->addColumn('message', 'text')
->addColumn(
'platform',
'enum',
[
'values' => [
'website',
'designer',
'admin'
],
'default' => 'website'
]
)
->addTimestamps('created', 'updated')
->addIndex(['email'])
->create();
}
}
57 changes: 57 additions & 0 deletions data/database/seeds/RoleSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Data\Database\Seeds;

use Phinx\Seed\AbstractSeed;
use Ramsey\Uuid\Codec\OrderedTimeCodec;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidFactory;

class RoleSeeder extends AbstractSeed
{
/**
* Run Method.
*
* Write your database seeder using this method.
*
* More information on writing seeders is available here:
* http://docs.phinx.org/en/latest/seeding.html
*
* @throws \Exception
*/
public function run()
{
$uuidFactory = $this->getUuidGenerator();

$role = $this->table('user_role');
$role->insert(
[
[
'uuid' => $uuidFactory->uuid1()->getBytes(),
'name' => 'admin'
],
[
'uuid' => $uuidFactory->uuid1()->getBytes(),
'name' => 'user'
],
[
'uuid' => $uuidFactory->uuid1()->getBytes(),
'name' => 'guest'
],
]
)->save();
}

/**
* @return UuidFactory
*/
protected function getUuidGenerator()
{
/** @var UuidFactory $factory */
$factory = clone Uuid::getFactory();
$codec = new OrderedTimeCodec($factory->getUuidBuilder());
$factory->setCodec($codec);

return $factory;
}
}
Empty file added data/language/.gitkeep
Empty file.
Binary file added data/language/da_DK/LC_MESSAGES/messages.mo
Binary file not shown.
Loading

0 comments on commit ca1d5b8

Please sign in to comment.