Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
backend:
- changed-files:
- any-glob-to-any-file:
- "src/app/**/*.php"
- "src/app/Packages/**/*.php"
- "src/routes/**/*.php"
- "src/config/**/*.php"

feature:
- head-branch: ['^feat', 'feature']

bug:
- head-branch: ['^fix', 'bugfix', 'hotfix']

refactor:
- head-branch: ['^refactor']

perf:
- head-branch: ['^perf']

release:
- base-branch: ['^release', '^main$']
Empty file.
18 changes: 18 additions & 0 deletions .github/workflows/pr-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR Labeler
on:
pull_request:
types: [opened, ready_for_review, synchronize]

jobs:
labeler:
timeout-minutes: 1
permissions:
contents: read
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
configuration-path: .github/labeler.yml
sync-labels: false
Empty file.
41 changes: 9 additions & 32 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,69 +19,46 @@ services:
mysql:
image: mysql:8.0
container_name: heritage-mysql
restart: unless-stopped
ports:
- "2306:3306"
environment:
MYSQL_DATABASE: world-heritage
MYSQL_DATABASE: world_heritage_local
MYSQL_ROOT_PASSWORD: world-heritage
MYSQL_USER: world-heritage
MYSQL_PASSWORD: world-heritage
volumes:
- db_data:/var/lib/mysql
ports: ["2306:3306"]
volumes: [db_data:/var/lib/mysql]

mysql-test:
image: mysql:8.0
container_name: heritage-mysql-test
restart: unless-stopped
ports:
- "2307:3306"
environment:
MYSQL_DATABASE: world_heritage_test
MYSQL_ROOT_PASSWORD: world-heritage
MYSQL_USER: world-heritage
MYSQL_PASSWORD: world-heritage
volumes:
- db_data_test:/var/lib/mysql
ports: ["2307:3306"]
volumes: [db_data_test:/var/lib/mysql]

phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: heritage-phpmyadmin
restart: unless-stopped
ports:
- "8080:80"
environment:
PMA_HOST: mysql
PMA_PORT: 3306
PMA_USER: world-heritage
PMA_PASSWORD: world-heritage
depends_on:
- mysql
ports: ["8080:80"]
depends_on: [mysql]

phpmyadmin-test:
image: phpmyadmin/phpmyadmin
container_name: heritage-phpmyadmin-test
restart: unless-stopped
ports:
- "8081:80"
environment:
PMA_HOST: mysql-test
PMA_PORT: 3306
PMA_USER: world-heritage
PMA_PASSWORD: world-heritage
depends_on:
- mysql-test

nginx:
image: nginx:alpine
container_name: heritage-nginx
ports:
- "1081:80"
volumes:
- ./src:/var/www
- ./environment/nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- app
ports: ["8081:80"]
depends_on: [mysql-test]

volumes:
db_data:
Expand Down
38 changes: 38 additions & 0 deletions src/app/Models/Country.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Models;

use App\Models\WorldHeritage;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Country extends Model
{
protected $table = 'countries';
protected $connection = 'mysql';

protected $fillable = [
'state_party_code',
'name_en',
'name_jp',
'region'
];

protected $primaryKey = 'state_party_code';
public $incrementing = false;
protected $keyType = 'string';
public $timestamps = false;

public function worldHeritageSites(): BelongsToMany
{
return $this->belongsToMany(
WorldHeritage::class,
'site_state_parties',
'state_party_code',
'world_heritage_site_id',
'state_party_code',
'id'
)->withPivot(['is_primary','inscription_year'])
->withTimestamps();
}
}
16 changes: 15 additions & 1 deletion src/app/Models/WorldHeritage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

namespace App\Models;

use App\Models\Country;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class WorldHeritage extends Model
{
protected $table = 'world_heritage_sites';
protected $connection = 'mysql';

protected $fillable = [
'id',
'unesco_id',
'official_name',
'name',
Expand Down Expand Up @@ -40,4 +41,17 @@ class WorldHeritage extends Model
'latitude' => 'float',
'longitude' => 'float',
];

public function countries(): BelongsToMany
{
return $this->belongsToMany(
Country::class,
'site_state_parties',
'world_heritage_site_id',
'state_party_code',
'id',
'state_party_code'
)->withPivot(['is_primary','inscription_year'])
->withTimestamps();
}
}
Loading