8000 For reviews by tboxmy · Pull Request #2 · tboxmy/corona-shift · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

For reviews #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/devcontainers/php:0-8.2

# Install MariaDB client
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y mariadb-client \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Install php-mysql driver
RUN docker-php-ext-install mysqli pdo pdo_mysql

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb
{
"name": "PHP & MariaDB",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// For use with PHP or Apache (e.g.php -S localhost:8080 or apache2ctl start)
"forwardPorts": [
8080,
3306,
9000
],
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-contrib/features/npm-package:1": {}
},

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}
36 changes: 36 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: mariadb:10.4
restart: unless-stopped
volumes:
- mariadb-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: mariadb
MYSQL_DATABASE: mariadb
MYSQL_USER: mariadb
MYSQL_PASSWORD: mariadb

# Add "forwardPorts": ["3306"] to **devcontainer.json** to forward MariaDB locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
mariadb-data:
23 changes: 1 addition & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,13 @@ Through this framework, it can be easily extended to automated shift scheduling
| Popper (npm) | 2.11.6 |
| dateFns | 2.29.3 |

Notes:

- JQuery is setup, however I have decided to continue without it at this stage as JavaScript is able to provide the required functions.
- Moment is setup, however dateFns is now implemented where possible to leverage at lighter code.

## Installing this project

```
git clone <SSH><USER><URL>
php artisan migrate
php artisan db:seed
php artisan db:seed --class=ExampleShiftsSeeder

OR individually load Seeder files
php artisan db:seed --class=DefaultUsersSeeder
php artisan db:seed --class=DefaultTypesSeeder
OR
php artisan migrate:fresh --seed --seeder=DefaultTypesSeeder

php artisan db:seed --class=DefaultDepartmentUserSeeder
```

- Configure database settings in the file .env
Expand Down Expand Up @@ -107,12 +94,4 @@ DB_USERNAME=postgres
DB_PASSWORD=postgres
```

## Bootstrap

Installed using Laravel mix

```
npm install bootstrap
npm install sass && npm install sass-loader
npm run dev
```
[Developer notes](/readme/README-DEVEL)
2 changes: 1 addition & 1 deletion config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'engine' => "innodb",
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
Expand Down
12 changes: 9 additions & 3 deletions database/migrations/2022_11_26_033410_create_shifts_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function up()
$table->id();
$table->string('name');
$table->string('description')->nullable();
$table->integer('shift_type_id');
// Postgresql
// $table->integer('shift_type_id');
$table->integer('parent_id')->nullable();
$table->integer('total_pax')->unsigned()->default(1);
$table->integer('region_id')->default(0)->comment('Shift region coverage where 0=All regions');
Expand All @@ -27,8 +28,13 @@ public function up()
$table->integer('published_by')->nullable();
$table->jsonb('options')->nullable();
$table->timestamps();
$table->foreign('parent_id')->references('id')->on('shifts')->onDelete('cascade');
$table->foreign('shift_type_id')->references('id')->on('shift_types');
// Postgresql
// $table->foreign('parent_id')->references('id')->on('shifts')->onDelete('cascade');
// $table->foreign('shift_type_id')->references('id')->on('shift_types')->onDelete('cascade');

// Mysql
$table->foreignId('shift_type_id')->nullable()->constrained('shift_types')->onDelete('set null');

});
}

Expand Down
15 changes: 11 additions & 4 deletions database/migrations/2022_11_26_033445_create_timeoffs_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ public function up()
$table->id();
$table->string('name');
$table->string('description')->nullable();
$table->integer('timeoff_type_id');
$table->integer('user_id');
// Postgresql
// $table->integer('timeoff_type_id');
// $table->integer('user_id');
$table->date('date')->default(\DB::raw('CURRENT_TIMESTAMP'));
$table->integer('created_by')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('timeoff_type_id')->references('id')->on('timeoff_types');

// Postgresql
// $table->foreign('user_id')->references('id')->on('users');
// $table->foreign('timeoff_type_id')->references('id')->on('timeoff_types');

// Mysql
$table->foreignId('user_id')->nullable()->consrained('users')->onDelete('set null');
$table->foreignId('timeoff_type_id')->nullable()->consrained('timeoff_types')->onDelete('set null');
});
}

Expand Down
15 changes: 11 additions & 4 deletions database/migrations/2022_11_27_153632_create_shift_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@ public function up()
{
Schema::create('shift_users', function (Blueprint $table) {
$table->id();
$table->integer('shift_id');
$table->integer('user_id');

// Postgresql
// $table->integer('shift_id');
// $table->integer('user_id');
$table->string('description')->nullable();
$table->integer('department_id');
$table->string('department_code');
$table->timestamp('start');
$table->timestamp('end');
$table->timestamp('start')->nullable();
$table->timestamp('end')->nullable();
$table->timestamp('clockin_at')->nullable();
$table->timestamp('clockout_at')->nullable();
$table->jsonb('options')->nullable();
$table->timestamps();
// Postgresql
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('shift_id')->references('id')->on('shifts');

// Mysql
$table->foreignId('user_id')->nullable()->consrained('users')->onDelete('set null');
$table->foreignId('shift_id')->nullable()->consrained('shifts')->onDelete('set null');
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ public function up()
{
Schema::create('user_profiles', function (Blueprint $table) {
$table->id();
$table->integer('user_id')->comment('users table');
// Postgresql
// $table->integer('user_id')->comment('users table');
$table->string('role')->default('staff')->nullable()->comment('Role is usage of system');
$table->integer('hourly_rate')->comment('salary rate at lowest currency unit. E.g cents for MYR currency')->default(100);
$table->string('timezone')->nullable();
$table->string('currency')->comment('refer to ISO code')->default('MYR');
$table->text('description')->nullable();
$table->jsonb('options')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
// Postgresql
// $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

// Mysql
$table->foreignId('user_id')->nullable()->consrained('users')->onDelete('set null');
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ public function up()
{
Schema::create('department_users', function (Blueprint $table) {
$table->id();
$table->integer('department_id');
$table->bigInteger('user_id')->unsigned()->index();

// Postgresql
// $table->integer('department_id');
// $table->bigInteger('user_id')->unsigned()->index();
$table->jsonb('properties')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('department_id')->references('id')->on('departments');

// Postgresql
// $table->foreign('user_id')->references('id')->on('users');
// $table->foreign('department_id')->references('id')->on('departments');

// Mysql
$table->foreignId('user_id')->nullable()->consrained('users')->onDelete('set null');
$table->foreignId('department_id')->nullable()->consrained('departments')->onDelete('set null');
});
}

Expand Down
Loading
0