Skip to content

Commit 06a1b0b

Browse files
authored
Merge pull request #71 from zigzagdev/feature/balkans
Add CI/CD files
2 parents d21cab4 + ab3c19c commit 06a1b0b

26 files changed

Lines changed: 1387 additions & 437 deletions

.github/labeler.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
backend:
2+
- changed-files:
3+
- any-glob-to-any-file:
4+
- "src/app/**/*.php"
5+
- "src/app/Packages/**/*.php"
6+
- "src/routes/**/*.php"
7+
- "src/config/**/*.php"
8+
9+
feature:
10+
- head-branch: ['^feat', 'feature']
11+
12+
bug:
13+
- head-branch: ['^fix', 'bugfix', 'hotfix']
14+
15+
refactor:
16+
- head-branch: ['^refactor']
17+
18+
perf:
19+
- head-branch: ['^perf']
20+
21+
release:
22+
- base-branch: ['^release', '^main$']

.github/workflows/phpstan_test.yml

Whitespace-only changes.

.github/workflows/pr-label.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: PR Labeler
2+
on:
3+
pull_request:
4+
types: [opened, ready_for_review, synchronize]
5+
6+
jobs:
7+
labeler:
8+
timeout-minutes: 1
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
issues: write
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/labeler@v5
16+
with:
17+
configuration-path: .github/labeler.yml
18+
sync-labels: false

.github/workflows/server_test.yml

Whitespace-only changes.

docker-compose.yml

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,69 +19,46 @@ services:
1919
mysql:
2020
image: mysql:8.0
2121
container_name: heritage-mysql
22-
restart: unless-stopped
23-
ports:
24-
- "2306:3306"
2522
environment:
26-
MYSQL_DATABASE: world-heritage
23+
MYSQL_DATABASE: world_heritage_local
2724
MYSQL_ROOT_PASSWORD: world-heritage
2825
MYSQL_USER: world-heritage
2926
MYSQL_PASSWORD: world-heritage
30-
volumes:
31-
- db_data:/var/lib/mysql
27+
ports: ["2306:3306"]
28+
volumes: [db_data:/var/lib/mysql]
3229

3330
mysql-test:
3431
image: mysql:8.0
3532
container_name: heritage-mysql-test
36-
restart: unless-stopped
37-
ports:
38-
- "2307:3306"
3933
environment:
4034
MYSQL_DATABASE: world_heritage_test
4135
MYSQL_ROOT_PASSWORD: world-heritage
4236
MYSQL_USER: world-heritage
4337
MYSQL_PASSWORD: world-heritage
44-
volumes:
45-
- db_data_test:/var/lib/mysql
38+
ports: ["2307:3306"]
39+
volumes: [db_data_test:/var/lib/mysql]
4640

4741
phpmyadmin:
4842
image: phpmyadmin/phpmyadmin
4943
container_name: heritage-phpmyadmin
50-
restart: unless-stopped
51-
ports:
52-
- "8080:80"
5344
environment:
5445
PMA_HOST: mysql
5546
PMA_PORT: 3306
5647
PMA_USER: world-heritage
5748
PMA_PASSWORD: world-heritage
58-
depends_on:
59-
- mysql
49+
ports: ["8080:80"]
50+
depends_on: [mysql]
6051

6152
phpmyadmin-test:
6253
image: phpmyadmin/phpmyadmin
6354
container_name: heritage-phpmyadmin-test
64-
restart: unless-stopped
65-
ports:
66-
- "8081:80"
6755
environment:
6856
PMA_HOST: mysql-test
6957
PMA_PORT: 3306
7058
PMA_USER: world-heritage
7159
PMA_PASSWORD: world-heritage
72-
depends_on:
73-
- mysql-test
74-
75-
nginx:
76-
image: nginx:alpine
77-
container_name: heritage-nginx
78-
ports:
79-
- "1081:80"
80-
volumes:
81-
- ./src:/var/www
82-
- ./environment/nginx/default.conf:/etc/nginx/conf.d/default.conf
83-
depends_on:
84-
- app
60+
ports: ["8081:80"]
61+
depends_on: [mysql-test]
8562

8663
volumes:
8764
db_data:

src/app/Models/Country.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use App\Models\WorldHeritage;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
8+
9+
class Country extends Model
10+
{
11+
protected $table = 'countries';
12+
protected $connection = 'mysql';
13+
14+
protected $fillable = [
15+
'state_party_code',
16+
'name_en',
17+
'name_jp',
18+
'region'
19+
];
20+
21+
protected $primaryKey = 'state_party_code';
22+
public $incrementing = false;
23+
protected $keyType = 'string';
24+
public $timestamps = false;
25+
26+
public function worldHeritageSites(): BelongsToMany
27+
{
28+
return $this->belongsToMany(
29+
WorldHeritage::class,
30+
'site_state_parties',
31+
'state_party_code',
32+
'world_heritage_site_id',
33+
'state_party_code',
34+
'id'
35+
)->withPivot(['is_primary','inscription_year'])
36+
->withTimestamps();
37+
}
38+
}

src/app/Models/WorldHeritage.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
namespace App\Models;
44

5+
use App\Models\Country;
56
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
68

79
class WorldHeritage extends Model
810
{
911
protected $table = 'world_heritage_sites';
1012
protected $connection = 'mysql';
1113

1214
protected $fillable = [
13-
'id',
1415
'unesco_id',
1516
'official_name',
1617
'name',
@@ -40,4 +41,17 @@ class WorldHeritage extends Model
4041
'latitude' => 'float',
4142
'longitude' => 'float',
4243
];
44+
45+
public function countries(): BelongsToMany
46+
{
47+
return $this->belongsToMany(
48+
Country::class,
49+
'site_state_parties',
50+
'world_heritage_site_id',
51+
'state_party_code',
52+
'id',
53+
'state_party_code'
54+
)->withPivot(['is_primary','inscription_year'])
55+
->withTimestamps();
56+
}
4357
}

0 commit comments

Comments
 (0)