Compare commits

...

No commits in common. "main" and "dev" have entirely different histories.
main ... dev

5421 changed files with 634654 additions and 4 deletions

45
.env Normal file
View File

@ -0,0 +1,45 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=b8e4c4620ab2c4f9e0f74deb028cca79
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
#DATABASE_URL="mysql://mamb:lakers06@db.dyb-tech.com:3306/la_liga?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=15&charset=utf8"
###< doctrine/doctrine-bundle ###
###> lexik/jwt-authentication-bundle ###
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=51429d81a28d5a6df251a9de746259e21d4721499e62ea4d155a316ec968f28c
###< lexik/jwt-authentication-bundle ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###
###> symfony/mailer ###
# MAILER_DSN=null://null
###< symfony/mailer ###

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
vendor/
var/

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

94
.idea/LaLiga-BackEnd.iml Normal file
View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="DMD\LaLigaApi\" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="DMD\LaLigaApi\Tests\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/cache" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/collections" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/common" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/dbal" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/deprecations" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/doctrine-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/doctrine-migrations-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/event-manager" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/inflector" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/instantiator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/lexer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/migrations" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/orm" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/persistence" />
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/sql-formatter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/egulias/email-validator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/lcobucci/clock" />
<excludeFolder url="file://$MODULE_DIR$/vendor/lcobucci/jwt" />
<excludeFolder url="file://$MODULE_DIR$/vendor/lexik/jwt-authentication-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/namshi/jose" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nelmio/api-doc-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nelmio/cors-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nikic/php-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/reflection-common" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/reflection-docblock" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpdocumentor/type-resolver" />
<excludeFolder url="file://$MODULE_DIR$/vendor/phpstan/phpdoc-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/cache" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/clock" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/event-dispatcher" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/log" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/cache" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/cache-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/clock" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/config" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/console" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/dependency-injection" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/deprecation-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/doctrine-bridge" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/dotenv" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/error-handler" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/event-dispatcher-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/filesystem" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/flex" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/framework-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-foundation" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-kernel" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mailer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/maker-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mime" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/options-resolver" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/password-hasher" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-grapheme" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php83" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/process" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/property-access" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/property-info" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/routing" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/runtime" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/security-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/security-core" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/security-csrf" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/security-http" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/service-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/stopwatch" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/string" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/translation-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/twig-bridge" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/twig-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/validator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-dumper" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/var-exporter" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/yaml" />
<excludeFolder url="file://$MODULE_DIR$/vendor/twig/twig" />
<excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
<excludeFolder url="file://$MODULE_DIR$/vendor/zircote/swagger-php" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="-370ff73f:190e707a569:-7ffa" />
</MTProjectMetadataState>
</option>
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/LaLiga-BackEnd.iml" filepath="$PROJECT_DIR$/.idea/LaLiga-BackEnd.iml" />
</modules>
</component>
</project>

107
.idea/php.xml Normal file
View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/doctrine/cache" />
<path value="$PROJECT_DIR$/vendor/doctrine/collections" />
<path value="$PROJECT_DIR$/vendor/doctrine/common" />
<path value="$PROJECT_DIR$/vendor/doctrine/dbal" />
<path value="$PROJECT_DIR$/vendor/doctrine/deprecations" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-bundle" />
<path value="$PROJECT_DIR$/vendor/doctrine/doctrine-migrations-bundle" />
<path value="$PROJECT_DIR$/vendor/doctrine/event-manager" />
<path value="$PROJECT_DIR$/vendor/doctrine/inflector" />
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
<path value="$PROJECT_DIR$/vendor/doctrine/lexer" />
<path value="$PROJECT_DIR$/vendor/doctrine/migrations" />
<path value="$PROJECT_DIR$/vendor/doctrine/orm" />
<path value="$PROJECT_DIR$/vendor/doctrine/persistence" />
<path value="$PROJECT_DIR$/vendor/doctrine/sql-formatter" />
<path value="$PROJECT_DIR$/vendor/egulias/email-validator" />
<path value="$PROJECT_DIR$/vendor/lcobucci/clock" />
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
<path value="$PROJECT_DIR$/vendor/lexik/jwt-authentication-bundle" />
<path value="$PROJECT_DIR$/vendor/namshi/jose" />
<path value="$PROJECT_DIR$/vendor/nelmio/api-doc-bundle" />
<path value="$PROJECT_DIR$/vendor/nelmio/cors-bundle" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-common" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/reflection-docblock" />
<path value="$PROJECT_DIR$/vendor/phpdocumentor/type-resolver" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpdoc-parser" />
<path value="$PROJECT_DIR$/vendor/psr/cache" />
<path value="$PROJECT_DIR$/vendor/psr/clock" />
<path value="$PROJECT_DIR$/vendor/psr/container" />
<path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/psr/log" />
<path value="$PROJECT_DIR$/vendor/symfony/cache" />
<path value="$PROJECT_DIR$/vendor/symfony/cache-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/clock" />
<path value="$PROJECT_DIR$/vendor/symfony/config" />
<path value="$PROJECT_DIR$/vendor/symfony/console" />
<path value="$PROJECT_DIR$/vendor/symfony/dependency-injection" />
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/doctrine-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/dotenv" />
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/symfony/event-dispatcher-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/filesystem" />
<path value="$PROJECT_DIR$/vendor/symfony/finder" />
<path value="$PROJECT_DIR$/vendor/symfony/flex" />
<path value="$PROJECT_DIR$/vendor/symfony/framework-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/http-foundation" />
<path value="$PROJECT_DIR$/vendor/symfony/http-kernel" />
<path value="$PROJECT_DIR$/vendor/symfony/mailer" />
<path value="$PROJECT_DIR$/vendor/symfony/maker-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
<path value="$PROJECT_DIR$/vendor/symfony/options-resolver" />
<path value="$PROJECT_DIR$/vendor/symfony/password-hasher" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-grapheme" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-mbstring" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php83" />
<path value="$PROJECT_DIR$/vendor/symfony/process" />
<path value="$PROJECT_DIR$/vendor/symfony/property-access" />
<path value="$PROJECT_DIR$/vendor/symfony/property-info" />
<path value="$PROJECT_DIR$/vendor/symfony/routing" />
<path value="$PROJECT_DIR$/vendor/symfony/runtime" />
<path value="$PROJECT_DIR$/vendor/symfony/security-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/security-core" />
<path value="$PROJECT_DIR$/vendor/symfony/security-csrf" />
<path value="$PROJECT_DIR$/vendor/symfony/security-http" />
<path value="$PROJECT_DIR$/vendor/symfony/service-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/stopwatch" />
<path value="$PROJECT_DIR$/vendor/symfony/string" />
<path value="$PROJECT_DIR$/vendor/symfony/translation-contracts" />
<path value="$PROJECT_DIR$/vendor/symfony/twig-bridge" />
<path value="$PROJECT_DIR$/vendor/symfony/twig-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/validator" />
<path value="$PROJECT_DIR$/vendor/symfony/var-dumper" />
<path value="$PROJECT_DIR$/vendor/symfony/var-exporter" />
<path value="$PROJECT_DIR$/vendor/symfony/yaml" />
<path value="$PROJECT_DIR$/vendor/twig/twig" />
<path value="$PROJECT_DIR$/vendor/webmozart/assert" />
<path value="$PROJECT_DIR$/vendor/zircote/swagger-php" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

34
Jenkinsfile vendored
View File

@ -1,9 +1,37 @@
pipeline {
pipeline {
agent any
stages {
stage('Show Branch Name and Project Name') {
stage('Clear current Branch') {
steps {
echo "The job name its ${JOB_NAME} at project dyb-tech.com - Jenkins"
echo "## Clearing - ${JOB_NAME} ##"
sh "ssh -o StrictHostKeyChecking=no laliga@webt.dyb-tech.com 'rm -rf /opt/srv/LaLiga-BackEnd/${BRANCH_NAME}'"
}
}
stage('Create path') {
steps {
echo "## Creating path in remote server ${BRANCH_NAME} ##"
sh "ssh -o StrictHostKeyChecking=no laliga@webt.dyb-tech.com 'mkdir -p /opt/srv/LaLiga-BackEnd/${BRANCH_NAME}'"
}
}
stage('Deploy') {
agent any
steps {
echo "## Deploying into ${BRANCH_NAME} ##"
sh "scp -o StrictHostKeyChecking=no -rp ./. laliga@webt.dyb-tech.com:/opt/srv/LaLiga-BackEnd/${BRANCH_NAME}"
}
}
stage('Update packages'){
agent any
steps {
echo "## Updating packages - composer on ${BRANCH_NAME}"
sh "ssh -o StrictHostKeyChecking=no laliga@webt.dyb-tech.com '/opt/srv/LaLiga-BackEnd/scripts/after_deploy.sh ${BRANCH_NAME}'"
}
}
stage('Add permissions') {
agent any
steps {
echo "## Fix permissions ${BRANCH_NAME} ##"
sh "ssh -o StrictHostKeyChecking=no laliga@webt.dyb-tech.com '/bin/bash /opt/srv/LaLiga-BackEnd/scripts/fix_perms.sh ${BRANCH_NAME}'"
}
}
}

View File

@ -1,3 +1,5 @@
# LaLiga-BackEnd
La Liga Back End
La Liga BackEnd Repository
Prueba borrado de cache..

17
bin/console Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php
use DMD\LaLigaApi\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};

78
composer.json Normal file
View File

@ -0,0 +1,78 @@
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.16",
"lexik/jwt-authentication-bundle": "^2.19",
"nelmio/api-doc-bundle": "^4.12",
"nelmio/cors-bundle": "*",
"symfony/console": "6.3.*",
"symfony/dotenv": "6.3.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "6.3.*",
"symfony/mailer": "6.3.*",
"symfony/runtime": "6.3.*",
"symfony/twig-bundle": "6.3.*",
"symfony/validator": "6.3.*",
"symfony/yaml": "6.3.*",
"ext-pdo": "*"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"DMD\\LaLigaApi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"DMD\\LaLigaApi\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "6.3.*"
}
},
"require-dev": {
"symfony/maker-bundle": "^1.50"
}
}

6566
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

13
config/bundles.php Normal file
View File

@ -0,0 +1,13 @@
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],
];

30
config/jwt/private.pem Normal file
View File

@ -0,0 +1,30 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQInDeviyrjeGECAggA
MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECOv8u+sIrYZyBIIEyH00Kuv7H9X/
pbCCgoQaisJ8oWyakZEvxJY+bvpteYMRqFBGfSSCwM198FhR49+gf29hWsr8bF3f
zoS+e8dnkzaVebBZ582FVAWUWdTBVct2CNHXDLTmwz/PJel/xGXXEqpoyb2wcxrr
+m3kEJq00AV2m5zDcPjL3lP71pEta2DwuPfKgs+n9KnqGO94zuj0Q+pe7hEVlfia
nKbmUWfXRSXscBv7dzt/Npl0pRiDkPCSPCKIXZfrVa8agxrUQbS422cVNtee8h5u
dqU5ZrnfmUOogRWW+/Is8HbdMPk1u1TGlHIBeJeJCeR7cype6KXFvZKqREP1MhH3
u9ge+J14PRqdm2ZeGpeKyvpnmrObE+qSeSShrttaytC6862IBJAcWs7+30oM/TUR
mpA8yj9G5wRgNB4kBYGfNCo3VgDL1be/ai0yUTeIpxOwszMidSXZ6lQ9KvJG55X8
kKmFfnLHqCx4D44WhtQPggcipZgsKePjFd348Wb2OWTRYpf66e5Q0Sua2+Faf6yL
8Y891ZFb2k68GNFS4sL0ZKvjiIRvbOYUt0wPebL5z5yJgza8/a7rC2cEv+vo/grw
npGGMc73iQ/jtFRYHNQBe4/uq5xO8eLxyrSdgHjIPek6N/yvP0BX994AV6KM9ew3
ovIgouBPfjF+jE5/wKfoFZFua2QVdm8kK0BcXqQkeKlgeBIXZEspuHqWRVAvH0Zx
zrqdraj8kTW9FtaRsTctwqsIuVBMXMm7h8ASl0nDSQRY+0xICdq0xO43Ie8UXx2i
8hQkRNa/zqmzbtenZhZXoKc/K6ylhA++7o/nEjwPZmfbgIndTdu5CDnH3qclX/Ls
cwTo1/mZuXyy0MCQ+qbagq2a4Ymbx5YQ304R8N6BieT2cnItWOWiImO1VgKQWlUp
9tNubgFFVCb+I6orguPwUPeptvXnxBERiTqFmlv7t1rK8+5twk07TXMQXQkHs20C
7MeKRUkXrQmRDiPRkRlEs2SmyPVqIT0eXi4ofGf57VQ4llkjBeDZIXzckMjFctZ4
2vBH2QCzWDb9+/8Gm/rDJh55VoJhyTGCiM6p87ebNHpmOtWviGThr02Fv8h+p3oZ
r5qWUU6k7XWS2UbL4FOcmctzsj1ieXPMeA6GjcRhzB48Ctp9FClYoaug1hTaupQc
7UYoy/j1kDVR+ft4Ld8RTTXC1M1ejHopEF3ssuLY7/t9tAA0Dyx0jBwJh+sZMZot
rKP/mOvmMzIQxQwgj05Q4vXF5g9rVCDVCKbb8AGWdktkG8SBe9M2xzEv7GWuOLwa
tmlRSD8V/hRpclCu5ry6zX/H/sjhDQkUkBRdO6drClyqEiX8HYkWsbkd791P8mgt
E42Fy02L7KyVa3wTn9QHu+9bwUBUI7cBmjindWXNdCbzNYoNevAwAgsfCoK0LZmp
BxbJ9e68yZXkIrEnxkl4tboaidhn/zDcf9msJfdZqwbfPtdDheIFGjgvZYPBxDzA
W9/4YGwwRFznycTobhLmBCYqpUrON7nXNdvMvSaG3mQevkRBRBVNTIxEufq6u/11
FrT/2kmFKAMPfypwV4PEZRaoJuxpnjWgMDQV1+W0HC0xdIlrTEySEmhTRiTdax8F
rvvz81Q6bF7l6y5xVcWv2g==
-----END ENCRYPTED PRIVATE KEY-----

9
config/jwt/public.pem Normal file
View File

@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwDsrme1BZmfXZF9XDBGY
l/eBtM04MTfHC5IV9HI4scoiFsQUUgxiESrE1ATwzd94E/V98W6xeApKpRlHKulb
/AxoBo+FaHZLIAEwfkSsqHhhcTATfdkI3nLd3OksbuqDg19nrWoStjTeig9jb3op
GezkL+fHcrUpBUFdT0jkuyR/hnIaYtWK6xalWodozJjPHxNC69X7p6xuWGPkRW2q
Plm1GzBl4hsvdZ0QfTJQC8aGPXII6Ug5jAySN4jvNSEQNDrnrZ1aiD+A8mnePaE/
le9Md4h/pMAn0ku9nv1dTMmFOl7xZUPpG2Qq7wilHyejtU2sLi8MciJaUSesg5ee
dwIDAQAB
-----END PUBLIC KEY-----

View File

@ -0,0 +1,19 @@
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null

View File

@ -0,0 +1,5 @@
maker:
# tell MakerBundle that all of your classes live in an
# Acme namespace, instead of the default App
# (e.g. Acme\Entity\Article, Acme\Command\MyCommand, etc)
root_namespace: 'DMD\LaLigaApi\'

View File

@ -0,0 +1,49 @@
doctrine:
dbal:
# url: '%env(resolve:DATABASE_URL)%'
url: 'mysql://mamb:lakers06@db.dyb-tech.com:3306/laliga?serverVersion=10.5.22-MariaDB&charset=utf8mb4'
# url: 'mysql://root:root@localhost:3307/la_liga?serverVersion=7.4.16&charset=utf8mb4'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '15'
#profiling_collect_backtrace: '%kernel.debug%'
orm:
auto_generate_proxy_classes: false
enable_lazy_ghost_objects: true
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
DMD\LaLigaApi:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'DMD\LaLigaApi\Entity'
alias: App
when@test:
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
when@prod:
doctrine:
orm:
auto_generate_proxy_classes: true
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system

View File

@ -0,0 +1,6 @@
doctrine_migrations:
migrations_paths:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/migrations'
enable_profiler: false

View File

@ -0,0 +1,25 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
http_method_override: false
handle_all_throwables: true
# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: null
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native
#esi: true
#fragments: true
php_errors:
log: true
when@test:
framework:
test: true
session:
storage_factory_id: session.storage.factory.mock_file

View File

@ -0,0 +1,5 @@
lexik_jwt_authentication:
secret_key: '%env(resolve:JWT_SECRET_KEY)%'
public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
pass_phrase: '%env(JWT_PASSPHRASE)%'
token_ttl: 18000

View File

@ -0,0 +1,3 @@
framework:
mailer:
dsn: 'smtp://soporteliga:dmdlakers06@localhost:8025?verify_peer=0'

View File

@ -0,0 +1,9 @@
nelmio_api_doc:
documentation:
info:
title: My App
description: This is an awesome app!
version: 1.0.0
areas: # to filter documented areas
path_patterns:
- ^/api(?!/doc$) # Accepts routes under /api except /api/doc

View File

@ -0,0 +1,10 @@
nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['*']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null

View File

@ -0,0 +1,12 @@
framework:
router:
utf8: true
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
#default_uri: http://localhost
when@prod:
framework:
router:
strict_requirements: null

View File

@ -0,0 +1,60 @@
security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
enable_authenticator_manager: true
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: DMD\LaLigaApi\Entity\User
property: email
firewalls:
login:
pattern: ^/api/login
stateless: true
json_login:
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
api:
pattern: ^/api
stateless: true
jwt: ~
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: app_user_provider
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/api/login, roles: PUBLIC_ACCESS }
- { path: ^/api/user/password, roles: PUBLIC_ACCESS }
- { path: ^/api/public, roles: PUBLIC_ACCESS }
- { path: ^/api/register, roles: PUBLIC_ACCESS }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
when@test:
security:
password_hashers:
# By default, password hashers are resource intensive and take time. This is
# important to generate secure password hashes. In tests however, secure hashes
# are not important, waste resources and increase test times. The following
# reduces the work factor to the lowest possible values.
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
algorithm: auto
cost: 4 # Lowest possible value for bcrypt
time_cost: 3 # Lowest possible value for argon
memory_cost: 10 # Lowest possible value for argon

View File

@ -0,0 +1,6 @@
twig:
default_path: '%kernel.project_dir%/templates'
when@test:
twig:
strict_variables: true

View File

@ -0,0 +1,13 @@
framework:
validation:
email_validation_mode: html5
# Enables validator auto-mapping support.
# For instance, basic validation constraints will be inferred from Doctrine's metadata.
#auto_mapping:
# App\Entity\: []
when@test:
framework:
validation:
not_compromised_password: false

5
config/preload.php Normal file
View File

@ -0,0 +1,5 @@
<?php
if (file_exists(dirname(__DIR__).'/var/cache/prod/DMD_LaLigaApi_KernelProdContainer.preload.php')) {
require dirname(__DIR__).'/var/cache/prod/DMD_LaLigaApi_KernelProdContainer.preload.php';
}

8
config/routes.yaml Normal file
View File

@ -0,0 +1,8 @@
controllers:
resource:
path: ../src/Controller/
namespace: DMD\LaLigaApi\Controller
type: attribute
api_login_check:
path: /api/login_check

View File

@ -0,0 +1,4 @@
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error

View File

@ -0,0 +1,12 @@
# Expose your documentation as JSON swagger compliant
app.swagger:
path: /api/doc.json
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger }
## Requires the Asset component and the Twig bundle
## $ composer require twig asset
#app.swagger_ui:
# path: /api/doc
# methods: GET
# defaults: { _controller: nelmio_api_doc.controller.swagger_ui }

31
config/services.yaml Normal file
View File

@ -0,0 +1,31 @@
# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
DMD\LaLigaApi\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
DMD\LaLigaApi\Exception\ExceptionListener:
tags:
- { name: kernel.event_listener, event: kernel.exception }
DMD\LaLigaApi\Service\User\Handlers\login\AuthenticationSuccessListener:
tags:
- { name: kernel.event_listener, event: lexik_jwt_authentication.on_authentication_success, method: onAuthenticationSuccessResponse }

0
migrations/.gitignore vendored Normal file
View File

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230831220137 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230918201118 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}

View File

@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230918202500 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE facility (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, address VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE file (id INT AUTO_INCREMENT NOT NULL, game_id INT DEFAULT NULL, player_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_8C9F3610E48FD905 (game_id), INDEX IDX_8C9F361099E6F5DF (player_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE game (id INT AUTO_INCREMENT NOT NULL, season_id INT DEFAULT NULL, facility_id INT DEFAULT NULL, home_team_id INT DEFAULT NULL, away_team_id INT DEFAULT NULL, points_home INT DEFAULT NULL, points_away INT DEFAULT NULL, planned_date DATETIME DEFAULT NULL, game_date_time DATETIME DEFAULT NULL, notes VARCHAR(350) DEFAULT NULL, INDEX IDX_232B318C4EC001D1 (season_id), INDEX IDX_232B318CA7014910 (facility_id), INDEX IDX_232B318C9C4C13F6 (home_team_id), INDEX IDX_232B318C45185D02 (away_team_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE league (id INT AUTO_INCREMENT NOT NULL, president_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, logo VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', points_per_win INT DEFAULT NULL, points_per_draw INT DEFAULT NULL, UNIQUE INDEX UNIQ_3EB4C318B40A33C7 (president_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE log (id INT AUTO_INCREMENT NOT NULL, payload JSON DEFAULT NULL, code INT DEFAULT NULL, message VARCHAR(550) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE player (id INT AUTO_INCREMENT NOT NULL, team_id INT DEFAULT NULL, first_name VARCHAR(255) DEFAULT NULL, last_name VARCHAR(255) DEFAULT NULL, position VARCHAR(255) DEFAULT NULL, jersey_number SMALLINT DEFAULT NULL, is_federated TINYINT(1) DEFAULT NULL, picture_file_name VARCHAR(255) DEFAULT NULL, birthday DATE DEFAULT NULL, INDEX IDX_98197A65296CD8AE (team_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE season (id INT AUTO_INCREMENT NOT NULL, league_id INT DEFAULT NULL, date_start DATE NOT NULL, date_end DATE DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_F0E45BA958AFC4DE (league_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE season_team (season_id INT NOT NULL, team_id INT NOT NULL, INDEX IDX_42A93A814EC001D1 (season_id), INDEX IDX_42A93A81296CD8AE (team_id), PRIMARY KEY(season_id, team_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE season_data (id INT AUTO_INCREMENT NOT NULL, team_id INT DEFAULT NULL, season_id INT DEFAULT NULL, captain_id INT DEFAULT NULL, points INT DEFAULT NULL, INDEX IDX_2BBA6FFD296CD8AE (team_id), INDEX IDX_2BBA6FFD4EC001D1 (season_id), INDEX IDX_2BBA6FFD3346729B (captain_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE team (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, first_name VARCHAR(255) DEFAULT NULL, last_name VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, profile_picture VARCHAR(255) DEFAULT NULL, birthday DATE DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE file ADD CONSTRAINT FK_8C9F3610E48FD905 FOREIGN KEY (game_id) REFERENCES game (id)');
$this->addSql('ALTER TABLE file ADD CONSTRAINT FK_8C9F361099E6F5DF FOREIGN KEY (player_id) REFERENCES player (id)');
$this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C4EC001D1 FOREIGN KEY (season_id) REFERENCES season (id)');
$this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318CA7014910 FOREIGN KEY (facility_id) REFERENCES facility (id)');
$this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C9C4C13F6 FOREIGN KEY (home_team_id) REFERENCES team (id)');
$this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C45185D02 FOREIGN KEY (away_team_id) REFERENCES team (id)');
$this->addSql('ALTER TABLE league ADD CONSTRAINT FK_3EB4C318B40A33C7 FOREIGN KEY (president_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE player ADD CONSTRAINT FK_98197A65296CD8AE FOREIGN KEY (team_id) REFERENCES team (id)');
$this->addSql('ALTER TABLE season ADD CONSTRAINT FK_F0E45BA958AFC4DE FOREIGN KEY (league_id) REFERENCES league (id)');
$this->addSql('ALTER TABLE season_team ADD CONSTRAINT FK_42A93A814EC001D1 FOREIGN KEY (season_id) REFERENCES season (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE season_team ADD CONSTRAINT FK_42A93A81296CD8AE FOREIGN KEY (team_id) REFERENCES team (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE season_data ADD CONSTRAINT FK_2BBA6FFD296CD8AE FOREIGN KEY (team_id) REFERENCES team (id)');
$this->addSql('ALTER TABLE season_data ADD CONSTRAINT FK_2BBA6FFD4EC001D1 FOREIGN KEY (season_id) REFERENCES season (id)');
$this->addSql('ALTER TABLE season_data ADD CONSTRAINT FK_2BBA6FFD3346729B FOREIGN KEY (captain_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE file DROP FOREIGN KEY FK_8C9F3610E48FD905');
$this->addSql('ALTER TABLE file DROP FOREIGN KEY FK_8C9F361099E6F5DF');
$this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318C4EC001D1');
$this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318CA7014910');
$this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318C9C4C13F6');
$this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318C45185D02');
$this->addSql('ALTER TABLE league DROP FOREIGN KEY FK_3EB4C318B40A33C7');
$this->addSql('ALTER TABLE player DROP FOREIGN KEY FK_98197A65296CD8AE');
$this->addSql('ALTER TABLE season DROP FOREIGN KEY FK_F0E45BA958AFC4DE');
$this->addSql('ALTER TABLE season_team DROP FOREIGN KEY FK_42A93A814EC001D1');
$this->addSql('ALTER TABLE season_team DROP FOREIGN KEY FK_42A93A81296CD8AE');
$this->addSql('ALTER TABLE season_data DROP FOREIGN KEY FK_2BBA6FFD296CD8AE');
$this->addSql('ALTER TABLE season_data DROP FOREIGN KEY FK_2BBA6FFD4EC001D1');
$this->addSql('ALTER TABLE season_data DROP FOREIGN KEY FK_2BBA6FFD3346729B');
$this->addSql('DROP TABLE facility');
$this->addSql('DROP TABLE file');
$this->addSql('DROP TABLE game');
$this->addSql('DROP TABLE league');
$this->addSql('DROP TABLE log');
$this->addSql('DROP TABLE player');
$this->addSql('DROP TABLE season');
$this->addSql('DROP TABLE season_team');
$this->addSql('DROP TABLE season_data');
$this->addSql('DROP TABLE team');
$this->addSql('DROP TABLE user');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231007212245 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user ADD note_list LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user DROP note_list');
}
}

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231007221519 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE season_data DROP FOREIGN KEY FK_2BBA6FFD3346729B');
$this->addSql('DROP INDEX IDX_2BBA6FFD3346729B ON season_data');
$this->addSql('ALTER TABLE season_data DROP captain_id');
$this->addSql('ALTER TABLE team ADD captain_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE team ADD CONSTRAINT FK_CAPTAIN_ID FOREIGN KEY (captain_id) REFERENCES user (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_CAPTAIN_ID ON team (captain_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE season_data ADD captain_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE season_data ADD CONSTRAINT FK_2BBA6FFD3346729B FOREIGN KEY (captain_id) REFERENCES user (id)');
$this->addSql('CREATE INDEX IDX_2BBA6FFD3346729B ON season_data (captain_id)');
$this->addSql('ALTER TABLE team DROP FOREIGN KEY FK_C4E0A61F3346729B');
$this->addSql('DROP INDEX UNIQ_C4E0A61F3346729B ON team');
$this->addSql('ALTER TABLE team DROP captain_id');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231007222620 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league ADD city VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE team RENAME INDEX uniq_captain_id TO UNIQ_C4E0A61F3346729B');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league DROP city');
$this->addSql('ALTER TABLE team RENAME INDEX uniq_c4e0a61f3346729b TO UNIQ_CAPTAIN_ID');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231007223332 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league ADD points_per_loss INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league DROP points_per_loss');
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231108232033 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility ADD season_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE facility ADD CONSTRAINT FK_105994B24EC001D1 FOREIGN KEY (season_id) REFERENCES season (id)');
$this->addSql('CREATE INDEX IDX_105994B24EC001D1 ON facility (season_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility DROP FOREIGN KEY FK_105994B24EC001D1');
$this->addSql('DROP INDEX IDX_105994B24EC001D1 ON facility');
$this->addSql('ALTER TABLE facility DROP season_id');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231109001241 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility ADD created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility DROP created_at');
}
}

View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240208210630 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE notification (id INT AUTO_INCREMENT NOT NULL, requesting_user_id INT DEFAULT NULL, league_id INT DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, message VARCHAR(280) DEFAULT NULL, is_accepted TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', team_id INT DEFAULT NULL, INDEX IDX_BF5476CA2A841BBC (requesting_user_id), INDEX IDX_BF5476CA58AFC4DE (league_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_NOTIFICATION_REQUESTING_USER_ID FOREIGN KEY (requesting_user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_NOTIFICATION_LEAGUE_ID FOREIGN KEY (league_id) REFERENCES league (id)');
$this->addSql('ALTER TABLE league ADD matches_between_teams INT DEFAULT NULL, ADD blocked_match_dates JSON DEFAULT NULL');
$this->addSql('ALTER TABLE log CHANGE payload payload LONGTEXT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_NOTIFICATION_REQUESTING_USER_ID');
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_NOTIFICATION_LEAGUE_ID');
$this->addSql('DROP TABLE notification');
$this->addSql('ALTER TABLE league DROP matches_between_teams, DROP blocked_match_dates');
$this->addSql('ALTER TABLE log CHANGE payload payload JSON DEFAULT NULL');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240210215035 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE season DROP date_end');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE season ADD date_end DATE DEFAULT NULL');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240210230354 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE custom_role (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_USER_ID (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE custom_role ADD CONSTRAINT FK_CUSTOM_ROLE_USER FOREIGN KEY (user_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE custom_role DROP FOREIGN KEY FK_CUSTOM_ROLE_USER');
$this->addSql('DROP TABLE custom_role');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240210231643 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE custom_role RENAME INDEX idx_user_id TO IDX_561F4297A76ED395');
$this->addSql('ALTER TABLE season ADD updated_at DATETIME DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE custom_role RENAME INDEX idx_561f4297a76ed395 TO IDX_USER_ID');
$this->addSql('ALTER TABLE season DROP updated_at');
}
}

View File

@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240307211223 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league DROP FOREIGN KEY FK_3EB4C318B40A33C7');
$this->addSql('DROP INDEX UNIQ_3EB4C318B40A33C7 ON league');
$this->addSql('ALTER TABLE league DROP president_id');
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_NOTIFICATION_REQUESTING_USER_ID');
$this->addSql('DROP INDEX IDX_BF5476CA2A841BBC ON notification');
$this->addSql('ALTER TABLE notification ADD user_to_notify_id INT NOT NULL, CHANGE requesting_user_id user_who_fired_event_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA6EEF4E6F FOREIGN KEY (user_who_fired_event_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA64958C8F FOREIGN KEY (user_to_notify_id) REFERENCES user (id)');
$this->addSql('CREATE INDEX IDX_BF5476CA6EEF4E6F ON notification (user_who_fired_event_id)');
$this->addSql('CREATE INDEX IDX_BF5476CA64958C8F ON notification (user_to_notify_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league ADD president_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE league ADD CONSTRAINT FK_3EB4C318B40A33C7 FOREIGN KEY (president_id) REFERENCES user (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_3EB4C318B40A33C7 ON league (president_id)');
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_BF5476CA6EEF4E6F');
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_BF5476CA64958C8F');
$this->addSql('DROP INDEX IDX_BF5476CA6EEF4E6F ON notification');
$this->addSql('DROP INDEX IDX_BF5476CA64958C8F ON notification');
$this->addSql('ALTER TABLE notification DROP user_to_notify_id, CHANGE user_who_fired_event_id requesting_user_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_NOTIFICATION_REQUESTING_USER_ID FOREIGN KEY (requesting_user_id) REFERENCES user (id)');
$this->addSql('CREATE INDEX IDX_BF5476CA2A841BBC ON notification (requesting_user_id)');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240310082537 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE notification ADD read_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', CHANGE is_accepted is_read TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE notification DROP read_at, CHANGE is_read is_accepted TINYINT(1) DEFAULT NULL');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240403225038 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE game ADD created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD updated_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE game DROP created_at, DROP updated_at');
}
}

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240516234124 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE file ADD season_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE file ADD CONSTRAINT FK_8C9F36104EC001D1 FOREIGN KEY (season_id) REFERENCES season (id)');
$this->addSql('CREATE INDEX IDX_8C9F36104EC001D1 ON file (season_id)');
$this->addSql('ALTER TABLE league ADD is_public TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE file DROP FOREIGN KEY FK_8C9F36104EC001D1');
$this->addSql('DROP INDEX IDX_8C9F36104EC001D1 ON file');
$this->addSql('ALTER TABLE file DROP season_id');
$this->addSql('ALTER TABLE league DROP is_public');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240522213147 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility ADD active TINYINT(1) DEFAULT NULL, ADD available_hours JSON DEFAULT NULL COMMENT \'(DC2Type:json)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility DROP active, DROP available_hours');
}
}

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240522221403 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility CHANGE available_hours available_hours JSON DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE team ADD home_facility_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE team ADD CONSTRAINT FK_HOME_FACILITY_ID FOREIGN KEY (home_facility_id) REFERENCES facility (id)');
$this->addSql('CREATE INDEX IDX_HOME_FACILITY ON team (home_facility_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE facility CHANGE available_hours available_hours JSON DEFAULT NULL COMMENT \'(DC2Type:json)\'');
$this->addSql('ALTER TABLE team DROP FOREIGN KEY FK_C4E0A61F1ACD745D');
$this->addSql('DROP INDEX IDX_C4E0A61F1ACD745D ON team');
$this->addSql('ALTER TABLE team DROP home_facility_id');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240526094546 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE custom_role ADD entity_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE team RENAME INDEX idx_home_facility TO IDX_C4E0A61F1ACD745D');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE custom_role DROP entity_id');
$this->addSql('ALTER TABLE team RENAME INDEX idx_c4e0a61f1acd745d TO IDX_HOME_FACILITY');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240602203312 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league DROP points_per_win, DROP points_per_draw, DROP points_per_loss');
$this->addSql('ALTER TABLE season ADD points_per_win INT DEFAULT NULL, ADD points_per_draw INT DEFAULT NULL, ADD points_per_loss INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE league ADD points_per_win INT DEFAULT NULL, ADD points_per_draw INT DEFAULT NULL, ADD points_per_loss INT DEFAULT NULL');
$this->addSql('ALTER TABLE season DROP points_per_win, DROP points_per_draw, DROP points_per_loss');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240615231250 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user ADD privacy_policy TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user DROP privacy_policy');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240714094237 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE season ADD games_per_week INT DEFAULT NULL');
$this->addSql('ALTER TABLE team ADD day_of_the_week_for_home_game VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE season DROP games_per_week');
$this->addSql('ALTER TABLE team DROP day_of_the_week_for_home_game');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240720184241 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE team ADD league_id INT DEFAULT NULL, ADD team_logo VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE team DROP league_id, DROP team_logo');
}
}

388
mysql-dump/LaLiga.sql Normal file

File diff suppressed because one or more lines are too long

11
public/.htaccess Normal file
View File

@ -0,0 +1,11 @@
#AuthUserFile "/etc/apache2/passwd.pass"
#AuthName "Please Enter Password"
#AuthType Basic
#Require valid-user
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

View File

@ -0,0 +1,52 @@
// This file is part of the API Platform project.
//
// (c) Kévin Dunglas <dunglas@gmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
function loadSwaggerUI(userOptions = {}) {
const data = JSON.parse(document.getElementById('swagger-data').innerText);
const defaultOptions = {
spec: data.spec,
dom_id: '#swagger-ui',
validatorUrl: null,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: 'StandaloneLayout'
};
const options = Object.assign({}, defaultOptions, userOptions);
const ui = SwaggerUIBundle(options);
const storageKey = 'nelmio_api_auth';
// if we have auth in storage use it
if (sessionStorage.getItem(storageKey)) {
try {
ui.authActions.authorize(JSON.parse(sessionStorage.getItem(storageKey)));
} catch (ignored) {
// catch any errors here so it does not stop script execution
}
}
// hook into authorize to store the auth in local storage when user performs authorization
const currentAuthorize = ui.authActions.authorize;
ui.authActions.authorize = function (payload) {
sessionStorage.setItem(storageKey, JSON.stringify(payload));
return currentAuthorize(payload);
};
// hook into logout to clear auth from storage if user logs out
const currentLogout = ui.authActions.logout;
ui.authActions.logout = function (payload) {
sessionStorage.removeItem(storageKey);
return currentLogout(payload);
};
window.ui = ui;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -0,0 +1,297 @@
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin:70px 0 0;
background: #f0f0f0;
}
/** HEADER **/
header:before {
content:"";
background-color:#27848E;
height:70px;
width:100%;
text-align:center;
position:fixed;
top:0;
z-index:100;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
header #logo {
position:fixed;
top : 35px;
right:40px;
z-index:102;
transform:translateY(-50%);
}
header #logo img {
height:48px;
background-color:rgba(40, 134, 144, 0.4)
}
/** INCREASE WRAPPER BLOC PADDING **/
#swagger-ui.api-platform .wrapper {
padding:0px 60px;
}
/** INFORMATIONS BLOC **/
#swagger-ui.api-platform .information-container.wrapper {
margin:0;
padding:10px 0 0;
width:100%;
max-width:100%;
background-color:white;
border-bottom:1px solid #ccc;
margin-bottom:30px;
}
#swagger-ui.api-platform .info .title {
color:#3caab5;
}
#swagger-ui.api-platform .info {
width: 100%;
max-width: 1460px;
padding: 0px 50px;
margin: 0px auto;
}
/** METHODS BLOCS **/
#swagger-ui.api-platform .opblock.opblock-get .opblock-summary-method {
background-color:#3CAAB5;
}
#swagger-ui.api-platform .opblock.opblock-put .opblock-summary-method {
background-color:#E6C229;
}
#swagger-ui.api-platform .opblock.opblock-post .opblock-summary-method {
background-color:#78BC61;
}
#swagger-ui.api-platform .opblock.opblock-delete .opblock-summary-method {
background-color:#ED6A5A;
}
#swagger-ui.api-platform .opblock.opblock-deprecated .opblock-summary-method {
background-color:#ebebeb;
}
#swagger-ui.api-platform .opblock.opblock-get .opblock-summary {
border-color:#3CAAB5;
}
#swagger-ui.api-platform .opblock.opblock-put .opblock-summary {
border-color:#E6C229;
}
#swagger-ui.api-platform .opblock.opblock-post .opblock-summary {
border-color:#78BC61;
}
#swagger-ui.api-platform .opblock.opblock-delete .opblock-summary {
border-color:#ED6A5A;
}
#swagger-ui.api-platform .opblock.opblock-deprecated .opblock-summary {
border-color:#ebebeb;
}
#swagger-ui.api-platform .opblock-summary-method {
border-radius:0;
padding:10px;
}
#swagger-ui.api-platform .opblock-summary {
padding:0;
}
#swagger-ui.api-platform .opblock-tag {
padding:5px 0;
margin:0 0 10px;
}
#swagger-ui.api-platform .opblock-tag:hover {
background-color:rgba(0,0,0,.1);
transform:scale(1.01);
}
#swagger-ui.api-platform .opblock-section-header, #swagger-ui.api-platform .opblock.opblock-get .opblock-section-header {
background-color:rgba(60,170,181,0.1);
box-shadow:none;
}
#swagger-ui.api-platform .opblock.opblock-post .opblock-section-header {
background-color:rgba(120,188,97,0.1);
}
#swagger-ui.api-platform .opblock.opblock-put .opblock-section-header {
background-color:rgba(230, 194, 41, 0.1);
}
#swagger-ui.api-platform .opblock.opblock-delete .opblock-section-header {
background-color:rgba(237,106,90,0.1);
}
#swagger-ui.api-platform .opblock.opblock-deprecated .opblock-section-header {
background-color:rgba(235,235,235,0.1);
}
#swagger-ui.api-platform .opblock {
border-radius:0;
background-color:white;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
margin:0 0 10px;
padding:0;
border:none!important;
}
#swagger-ui .topbar {
display: none;
}
/** FORMATS **/
#formats {
text-align:right;
font-family: sans-serif;
width: 100%;
max-width: 1460px;
padding: 0px 60px;
margin:0 auto;
}
/** BUTTONS **/
#swagger-ui.api-platform .btn.execute {
background-color:#3CAAB5;
border-color:#3CAAB5;
animation:none;
transition:all ease 0.3s;
}
#swagger-ui.api-platform .btn.execute:hover {
background-color:#288690;
border-color:#288690;
}
#swagger-ui.api-platform .execute-wrapper {
text-align:center;
}
#swagger-ui.api-platform .execute-wrapper .btn {
width:auto;
padding:10px 40px;
}
#swagger-ui.api-platform .btn-group {
max-width: 500px;
margin-left: auto;
margin-right: auto;
}
#swagger-ui.api-platform .btn-group .btn {
padding:10px 40px;
}
#swagger-ui.api-platform .btn {
transition:all ease 0.2s;
box-shadow:none;
background-color: #f7f7f7
}
#swagger-ui.api-platform .btn:hover {
background-color:rgba(65,68,78,0.1);
border-color:transparent;
}
#swagger-ui.api-platform .btn.cancel:hover {
background-color:rgba(237,106,90,0.1);
}
#swagger-ui.api-platform .btn.authorize:hover {
background-color:rgba(120,188,97,0.1);
}
#swagger-ui.api-platform select {
box-shadow:none;
cursor:pointer;
}
/** FIX TABS SEPARATOR **/
#swagger-ui.api-platform .tab li:first-of-type:after {
content : none;
}
#swagger-ui.api-platform .tab li {
padding:0px 5px;
border-right:1px solid rgba(0,0,0,.2);
}
#swagger-ui.api-platform .tab li:last-of-type {
border-right:none;
}
/** REMOVE HIGHLIGHTS FOCUS INPUTS **/
#swagger-ui.api-platform input:focus,
#swagger-ui.api-platform select:focus,
#swagger-ui.api-platform textarea:focus,
#swagger-ui.api-platform button:focus {
outline: none;
}
/** REMOVE TITILIUM FONT **/
.swagger-ui .opblock-tag,
.swagger-ui .opblock .opblock-section-header label,
.swagger-ui .opblock .opblock-section-header h4,
.swagger-ui .opblock .opblock-summary-method,
.swagger-ui .tab li,
.swagger-ui .scheme-container .schemes>label,
.swagger-ui .loading-container .loading:after,
.swagger-ui .btn,
.swagger-ui .btn.cancel,
.swagger-ui select,
.swagger-ui label,
.swagger-ui .dialog-ux .modal-ux-content h4,
.swagger-ui .dialog-ux .modal-ux-header h3,
.swagger-ui section.models h4,
.swagger-ui section.models h5,
.swagger-ui .model-title,
.swagger-ui .parameter__name,
.swagger-ui .topbar a,
.swagger-ui .topbar .download-url-wrapper .download-url-button,
.swagger-ui .info .title small pre,
.swagger-ui .scopes h2,
.swagger-ui .errors-wrapper hgroup h4 {
font-family: sans-serif !important;
}
#swagger-ui-logos {
position: absolute;
width:0;
height:0;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

9
public/index.php Normal file
View File

@ -0,0 +1,9 @@
<?php
use DMD\LaLigaApi\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};

0
src/Controller/.gitignore vendored Normal file
View File

View File

@ -0,0 +1,31 @@
<?php
namespace DMD\LaLigaApi\Controller;
use PDO;
use PDOException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class AdminController extends AbstractController
{
#[Route('/admin/db-check', name: 'app_check_db', methods: ['GET'])]
public function index(): Response
{
$host = 'db.dyb-tech.com';
$dbname = 'laliga';
$username = 'mamb';
$password = 'lakers06';
try {
$dbConnection = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return new JsonResponse("Connected successfully");
}
catch(PDOException $e)
{
return new JsonResponse("Connection failed: " . $e->getMessage());
}
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace DMD\LaLigaApi\Controller;
use DMD\LaLigaApi\Service\League\acceptJoinLeagueRequest\HandleAcceptJoinLeagueRequest;
use DMD\LaLigaApi\Service\League\createLeague\HandleCreateLeague;
use DMD\LaLigaApi\Service\League\declineJoinLeagueRequest\HandleDeclineJoinLeagueRequest;
use DMD\LaLigaApi\Service\League\getAllLeagues\HandleGetAllLeagues;
use DMD\LaLigaApi\Service\League\getLeagueById\HandleGetLeagueById;
use DMD\LaLigaApi\Service\League\newJoinLeagueRequest\HandleNewJoinLeagueRequest;
use DMD\LaLigaApi\Service\League\joinTeam\HandleCaptainRequest;
use DMD\LaLigaApi\Service\League\updateLeague\HandleUpdateLeague;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Routing\Annotation\Route;
class LeagueController extends AbstractController
{
#[Route('/api/league/create', name: 'app_league', methods: ['POST'])]
public function createLeague(Request $request, HandleCreateLeague $handleCreateLeague): JsonResponse
{
return $handleCreateLeague($request);
}
#[Route('/api/league/{leagueId}', name: 'app_get_put_league', methods: ['GET', 'PUT'])]
public function getOrUpdateLeagueById(Request $request, HandleGetLeagueById $handleGetLeagueById, HandleUpdateLeague $handleUpdateLeague, int $leagueId): JsonResponse
{
if ($request->getMethod() == 'GET')
{
return $handleGetLeagueById($request, $leagueId);
}
return $handleUpdateLeague($request, $leagueId);
}
#[Route('/api/league/{leagueId}/join', name: 'app_join_league', methods: ['PUT'])]
public function joinLeague(Request $request, HandleNewJoinLeagueRequest $handleJoinLeague, int $leagueId): JsonResponse
{
return $handleJoinLeague($request, $leagueId);
}
/**
* @throws TransportExceptionInterface
*/
#[Route('/api/league/{leagueId}/team/{teamId}', name: 'app_join_team', methods: ['PUT'])]
public function joinTeam(Request $request, HandleCaptainRequest $handleCaptainRequest, int $leagueId, int $teamId): JsonResponse
{
return $handleCaptainRequest($request, $leagueId, $teamId);
}
#[Route('/api/public/league', name: 'app_get_all_leagues', methods: ['GET'])]
public function getAllLeagues(HandleGetAllLeagues $handleGetAllLeagues): JsonResponse
{
return $handleGetAllLeagues();
}
/**
* @throws TransportExceptionInterface
*/
#[Route('api/league/{leagueId}/user/{userId}/accept', name: 'app_accept_join_request', methods: ['GET'])]
public function acceptJoinRequest(
Request $request,
HandleAcceptJoinLeagueRequest $handleAcceptJoinLeagueRequest,
int $leagueId,
int $userId
): JsonResponse
{
return $handleAcceptJoinLeagueRequest($request, $leagueId, $userId);
}
#[Route('api/league/{leagueId}/decline/{captainId}', name: 'app_decline_join_request', methods: ['GET'])]
public function declineJoinRequest(Request $request, HandleDeclineJoinLeagueRequest $handleDeclineJoinRequest, int $leagueId, int $captainId): JsonResponse
{
return $handleDeclineJoinRequest($request, $leagueId, $captainId);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace DMD\LaLigaApi\Controller;
use DMD\LaLigaApi\Service\User\Handlers\getNotifications\HandleGetNotifications;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class NotificationController extends AbstractController
{
#[Route('/api/notifications', name: 'app_get_notifications')]
public function getAllNotifications(HandleGetNotifications $handleGetNotifications): Response
{
return $handleGetNotifications();
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace DMD\LaLigaApi\Controller;
use DMD\LaLigaApi\Service\Season\addTeam\HandleAddTeamList;
use DMD\LaLigaApi\Service\Season\createFacilities\HandleCreateFacilities;
use DMD\LaLigaApi\Service\Season\createGameCalendar\HandleCreateGameCalendarRequest;
use DMD\LaLigaApi\Service\Season\createSeason\HandleCreateSeason;
use DMD\LaLigaApi\Service\Season\getAllFacilities\HandleGetAllFacilities;
use DMD\LaLigaApi\Service\Season\getAllTeams\HandleGetSeasonTeams;
use DMD\LaLigaApi\Service\Season\getSeasonById\HandleGetSeasonById;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class SeasonController extends AbstractController
{
#[Route('/api/league/{leagueId}/season/create', name: 'app_add_season', methods: ['POST'])]
public function addSeason(Request $request, HandleCreateSeason $handleCreateSeason, int $leagueId): JsonResponse
{
return $handleCreateSeason($request, $leagueId);
}
#[Route('/api/league/{leagueId}/season/{seasonId}', name: 'app_get_season_by_id', methods: ['GET'])]
public function getSeasonById(Request $request, HandleGetSeasonById $handleGetSeasonById, int $leagueId, int $seasonId): JsonResponse
{
return $handleGetSeasonById($request, $leagueId, $seasonId);
}
#[Route('/api/league/{leagueId}/season/{seasonId}/team', name: 'app_add_team', methods: ['POST'])]
public function addTeam(Request $request, HandleAddTeamList $handleAddTeam, int $leagueId, int $seasonId): JsonResponse
{
return $handleAddTeam($request, $leagueId, $seasonId);
}
#[Route('/api/league/{leagueId}/season/{seasonId}/team', name: 'app_get_season_teams', methods: ['GET'])]
public function getSeasonTeams(Request $request, HandleGetSeasonTeams $handleGetAllTeams, int $leagueId, int $seasonId): JsonResponse
{
return $handleGetAllTeams($request, $leagueId, $seasonId);
}
#[Route('/api/league/{leagueId}/season/{seasonId}/facilities/create', name: 'app_create_facilities', methods: ['POST'])]
public function createFacilities(Request $request, HandleCreateFacilities $handleCreateFacilities, int $leagueId, int $seasonId): JsonResponse
{
return $handleCreateFacilities($request, $leagueId, $seasonId);
}
#[Route('/api/league/{leagueId}/season/{seasonId}/facilities/', name: 'app_get_all_facilities', methods: ['GET'])]
public function getAllFacilities(Request $request, HandleGetAllFacilities $handleGetAllFacilities, int $leagueId, int $seasonId): JsonResponse
{
return $handleGetAllFacilities($request, $leagueId, $seasonId);
}
#[Route('/api/league/{leagueId}/season/{seasonId}/calendar', name: 'app_create_calendar', methods: ['POST'])]
public function createCalendar(Request $request, HandleCreateGameCalendarRequest $handleCreateGameCalendarRequest, int $leagueId, int $seasonId): JsonResponse
{
return $handleCreateGameCalendarRequest($request, $leagueId, $seasonId);
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace DMD\LaLigaApi\Controller;
use DMD\LaLigaApi\Repository\UserRepository;
use DMD\LaLigaApi\Service\User\Handlers\delete\HandleDeleteUser;
use DMD\LaLigaApi\Service\User\Handlers\getRelationships\HandleGetRelationships;
use DMD\LaLigaApi\Service\User\Handlers\update\HandleUpdateUser;
use DMD\LaLigaApi\Service\User\Handlers\register\HandleRegistration;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
class UserController extends AbstractController
{
#[Route('/api/register', name: 'app_user_register', methods: ['POST'])]
public function createUser(Request $request, HandleRegistration $handleRegistration): JsonResponse
{
return $handleRegistration($request);
}
#[Route('/api/user/', name: 'app_user_delete', methods: ['DELETE'])]
public function deleteUser(Request $request, HandleDeleteUser $handleDeleteUser): JsonResponse
{
return $handleDeleteUser($request);
}
#[Route('/api/user/edit', name: 'app_update_user', methods: ['PUT'])]
public function updateUser(Request $request, HandleUpdateUser $handleUpdateUser): JsonResponse
{
return $handleUpdateUser($request);
}
#[Route('/api/user/relationships', name: 'app_get_user_relationships', methods: ['GET'])]
public function getUserRelationships(Request $request, HandleGetRelationships $handleGetRelationships): JsonResponse
{
return $handleGetRelationships($request);
}
#[Route('/api/user/password', name: 'app_user_change_password', methods: ['PUT'])]
public function changePassword(
Request $request,
UserRepository $userRepository,
UserPasswordHasherInterface $passwordHasher,
EntityManagerInterface $entityManager
): JsonResponse
{
$user = $userRepository->findOneBy([
'email' => ($request->toArray())['username']
]);
if (is_null($user))
{
throw new HttpException(
Response::HTTP_NOT_FOUND,
'User not found.'
);
}
$hashedPassword = $passwordHasher->hashPassword($user, ($request->toArray())['newPassword']);
$user->setPassword($hashedPassword);
$entityManager->persist($user);
$entityManager->flush($user);
$entityManager->clear();
return new JsonResponse([
'success' => true
]);
}
}

58
src/Dto/CustomRoleDto.php Normal file
View File

@ -0,0 +1,58 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\CustomRole;
class CustomRoleDto
{
public int $id;
public string $name;
public \DateTimeImmutable $createdAt;
public int $userId;
public function toArray(): array
{
return [
'id' => $this->id ?? '',
'name' => $this->name ?? '',
'userId' => $this->userId ?? '',
'createdAt' => $this->createdAt ? $this->createdAt->format('Y-m-d H:i:s') : ''
];
}
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['name']))
{
$this->name = $dataList['name'];
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dataList['createdAt']);
}
}
public function fillFromObject(CustomRole $customRole): void
{
if (!is_null($customRole->getId()))
{
$this->id = $customRole->getId();
}
if (!is_null($customRole->getName()))
{
$this->name = $customRole->getName();
}
if (!is_null($customRole->getCreatedAt()))
{
$this->name = $customRole->getCreatedAt();
}
if (!is_null(($customRole->getUser())->getId()))
{
$this->userId = ($customRole->getUser())->getId();
}
}
}

112
src/Dto/FacilityDto.php Normal file
View File

@ -0,0 +1,112 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\Facility;
use DMD\LaLigaApi\Exception\ValidationException;
use phpDocumentor\Reflection\Types\Integer;
class FacilityDto
{
public int $id;
public string $name;
public string $address;
public array $availableHourList;
public bool $active;
public array $gameDtoList;
public array $seasonDtoList;
public \DateTimeImmutable $createdAt;
public array $validationErrors;
public function toArray(): array
{
return [
'id' => $this->id ?? '',
'name' => $this->name ?? '',
'address' => $this->address ?? '',
'availableHours' => $this->availableHourList ?? [],
'createdAt' => !empty($this->createdAt) ? $this->createdAt->format('Y-m-d H:i:s') : ''
];
}
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['name']))
{
$this->name = $dataList['name'];
}
if (!empty($dataList['address']))
{
$this->address = $dataList['address'];
}
if (isset($dataList['active']))
{
$this->active = $dataList['active'];
}
if (isset($dataList['availableHours']))
{
$this->availableHourList = $dataList['availableHours'];
}
if (!empty($dataList['seasonList']))
{
foreach ($dataList['seasonList'] as $seasonItem)
{
$seasonDto = new SeasonDto();
$seasonDto->fillFromArray($seasonItem);
$this->seasonDtoList[] = $seasonDto;
}
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dataList['createdAt'], new \DateTimeZone('Europe/Madrid'));
}
}
public function fillFromEntity(Facility $facilityEntity): void
{
if ($facilityEntity->getId() !== null)
{
$this->id = $facilityEntity->getId();
}
if ($facilityEntity->getName() !== null)
{
$this->name = $facilityEntity->getName();
}
if ($facilityEntity->getAddress() !== null)
{
$this->address = $facilityEntity->getAddress();
}
if ($facilityEntity->getAvailableHours() !== null)
{
$this->availableHourList = $facilityEntity->getAvailableHours();
}
if ($facilityEntity->getCreatedAt() !== null)
{
$this->createdAt =$facilityEntity->getCreatedAt();
}
}
public function validate(): void
{
if (empty($this->name))
{
$this->validationErrors[] = 'El nombre del pabellón no puede estar vacío.';
}
if (empty($this->address))
{
$this->validationErrors[] = 'La dirección del pabellón no puede estar vacío.';
}
if (empty($this->availableHourList))
{
$this->validationErrors[] = 'Las horas disponibles del pabellón no pueden estar vacías.';
}
if (!empty($this->validationErrors))
{
throw new ValidationException($this->validationErrors);
}
}
}

71
src/Dto/FileDto.php Normal file
View File

@ -0,0 +1,71 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\File;
class FileDto
{
public int $id;
public string $name;
public string $type;
public \DateTime $createdAt;
public GameDto $gameDto;
public PlayerDto $playerDto;
public SeasonDto $seasonDto;
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['name']))
{
$this->name = $dataList['name'];
}
if (!empty($dataList['type']))
{
$this->type = $dataList['type'];
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $dataList['createdAt']);
}
}
public function fillFromObject(File $fileEntity): void
{
if ($fileEntity->getId() !== null)
{
$this->id = $fileEntity->getId();
}
if ($fileEntity->getName() !== null)
{
$this->name = $fileEntity->getName();
}
if ($fileEntity->getPlayer() !== null)
{
$playerDto = new PlayerDto();
$playerDto->fillFromObject($fileEntity->getPlayer());
$this->playerDto = $playerDto;
}
if ($fileEntity->getSeason() !== null)
{
$seasonDto = new SeasonDto();
$seasonDto->fillFromEntity($fileEntity->getSeason());
$this->seasonDto = $seasonDto;
}
if ($fileEntity->getGame() !== null)
{
$gameDto = new GameDto();
$gameDto->fillFromObject($fileEntity->getGame());
$this->gameDto = $gameDto;
}
}
public function validate(): void
{
}
}

194
src/Dto/GameDto.php Normal file
View File

@ -0,0 +1,194 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\Game;
class GameDto
{
public int $id;
public TeamDto $homeTeamDto;
public TeamDto $awayTeamDto;
public \DateTime $plannedDate;
public \DateTime $gameDateTime;
public string $notes;
public array $fileDtoList;
public SeasonDto $seasonDto;
public FacilityDto $facilityDto;
public int $pointsHome;
public int $pointsAway;
public \DateTimeImmutable $createdAt;
public \DateTimeImmutable $updatedAt;
public array $validationErrors;
public function toArray(): array
{
$cleanResponseArray = [];
$responseArray = [
'id' => $this->id ?? null,
'homeTeam' => $this->homeTeamDto->toArray() ?? [],
'awayTeam' => $this->awayTeamDto->toArray() ?? [],
'plannedDate' => !empty($this->plannedDate) ? $this->plannedDate->format('Y-m-d H:i:s') : null,
'gameDateTime' => !empty($this->gameDateTime) ? $this->gameDateTime->format('Y-m-d H:i:s') : null,
'season' => $this->seasonDto->createSeasonArray() ?? [],
'notes' => $this->notes ?? null,
'facility' => $this->facilityDto->toArray() ?? [],
'pointsHome' => $this->pointsHome ?? 0,
'pointsAway' => $this->pointsAway ?? 0,
'createdAt' => !empty($this->createdAt) ? $this->createdAt->format('Y-m-d H:i:s') : null,
'updatedAt' => !empty($this->updatedAt) ? $this->updatedAt->format('Y-m-d H:i:s') : null
];
foreach ($responseArray as $key => $value)
{
if ($value !== null)
{
$cleanResponseArray[$key] = $value;
}
}
return $cleanResponseArray;
}
public function fillFromArray(array $dataList): void
{
if (!empty($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['plannedDate']))
{
$this->plannedDate = new \DateTime($dataList['plannedDate']);
}
if (!empty($dataList['gameDateTime']))
{
$this->gameDateTime = new \DateTime($dataList['gameDateTime']);
}
if (!empty($dataList['notes']))
{
$this->notes = $dataList['notes'];
}
if (!empty($dataList['pointsHome']))
{
$this->pointsHome = $dataList['pointsHome'];
}
if (!empty($dataList['pointsAway']))
{
$this->pointsAway = $dataList['pointsAway'];
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = new \DateTimeImmutable($dataList['createdAt'], new \DateTimeZone('Europe/Madrid'));
}
if (!empty($dataList['updatedAt']))
{
$this->updatedAt = new \DateTimeImmutable($dataList['updatedAt'], new \DateTimeZone('Europe/Madrid'));
}
}
public function fillFromObject(Game $gameEntity): void
{
if ($gameEntity->getId() !== null)
{
$this->id = $gameEntity->getId();
}
if ($gameEntity->getSeason() !== null)
{
$seasonDto = new SeasonDto();
$seasonDto->fillFromEntity($gameEntity->getSeason());
$this->seasonDto = $seasonDto;
}
if ($gameEntity->getFacility() !== null)
{
$facilityDto = new FacilityDto();
$facilityDto->fillFromEntity($gameEntity->getFacility());
$this->facilityDto = $facilityDto;
}
if ($gameEntity->getHomeTeam() !== null)
{
$teamDto = new TeamDto();
$teamDto->fillFromEntity($gameEntity->getHomeTeam());
$this->homeTeamDto = $teamDto;
}
if ($gameEntity->getAwayTeam() !== null)
{
$teamDto = new TeamDto();
$teamDto->fillFromEntity($gameEntity->getAwayTeam());
$this->awayTeamDto = $teamDto;
}
if ($gameEntity->getFiles() !== null)
{
$fileIterator = $gameEntity->getFiles()->getIterator();
foreach ($fileIterator as $fileEntity)
{
$fileDto = new FileDto();
$fileDto->fillFromObject($fileEntity);
$this->fileDtoList[] = $fileDto;
}
}
if ($gameEntity->getGameDateTime() !== null)
{
$this->gameDateTime = new \DateTime($gameEntity->getGameDateTime()->format('Y-m-d H:i:s'));
}
if ($gameEntity->getCreatedAt() !== null)
{
$this->createdAt = $gameEntity->getCreatedAt();
}
if ($gameEntity->getUpdatedAt() !== null)
{
$this->createdAt = $gameEntity->getUpdatedAt();
}
if ($gameEntity->getPlannedDate() !== null)
{
$this->plannedDate = new \DateTime($gameEntity->getPlannedDate()->format('Y-m-d H:i:s'));
}
if ($gameEntity->getNotes() !== null)
{
$this->notes = $gameEntity->getNotes();
}
if ($gameEntity->getNotes() !== null)
{
$this->notes = $gameEntity->getNotes();
}
if ($gameEntity->getPointsAway() !== null)
{
$this->pointsAway = $gameEntity->getPointsAway();
}
if ($gameEntity->getPointsHome() !== null)
{
$this->pointsAway = $gameEntity->getPointsHome();
}
}
public function validate(): void
{
if (empty($this->name))
{
$this->validationErrors[] = 'El nombre no puede estar vacío.';
}
if (
empty($this->pointsPerWin)
)
{
$this->validationErrors[] = 'Los puntos por partido ganado no pueden estar vacíos.';
}
if (
isset($this->pointsPerDraw, $this->pointsPerWin, $this->pointsPerLoss) &&
(($this->pointsPerWin <= $this->pointsPerDraw) ||
($this->pointsPerWin <= $this->pointsPerLoss))
)
{
$this->validationErrors[] = 'Los puntos por partido ganado deben ser superiores a los puntos por empate y por perdida.';
}
if (($this->pointsPerDraw > $this->pointsPerWin))
{
$this->validationErrors[] = 'Los puntos por empate deben ser inferiores a los puntos por partido ganado.';
}
if (($this->pointsPerDraw < $this->pointsPerLoss))
{
$this->validationErrors[] = 'Los puntos por empate deben ser superiores a los puntos por partido perdido.';
}
if ($this->pointsPerWin + $this->pointsPerDraw + $this->pointsPerLoss > 20)
{
$this->validationErrors[] = 'La suma de los puntos por partidos ganados, perdidos y empatados no puede ser superior a 20.';
}
}
}

186
src/Dto/LeagueDto.php Normal file
View File

@ -0,0 +1,186 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Exception\ValidationException;
use DMD\LaLigaApi\Entity\League;
class LeagueDto
{
public int $id;
public string $name;
public string $city;
public string $logo;
public string $description;
public int $matchesBetweenTeams;
public array $blockedMatchDates;
public bool $active;
public array $seasonDtoList;
public int $presidentId;
public bool $isPublic;
public \DateTimeImmutable $createdAt;
public array $validationErrors;
public function toArray(): array
{
$seasonIdList = [];
if (!empty($this->seasonDtoList))
{
foreach ($this->seasonDtoList as $seasonDto)
{
$seasonIdList[] = $seasonDto->id;
}
}
return [
'id' => $this->id ?? null,
'name' => $this->name ?? null,
'city' => $this->city ?? null,
'logo' => $this->logo ?? null,
'description' => $this->description ?? null,
'matchesBetweenTeams' => $this->matchesBetweenTeams ?? [],
'blockedMatchDates' => $this->blockedMatchDates ?? [],
'active' => $this->active,
'isPublic' => $this->isPublic ?? null,
'seasonIdList' => $seasonIdList,
'presidentId' => $this->presidentId ?? null,
'createdAt' => !empty($this->createdAt) ? $this->createdAt->format('Y-m-d H:i:s') : null
];
}
public function getAllLeaguesArray(): array
{
$seasonCount = !empty($this->seasonDtoList) ? count($this->seasonDtoList) : 0;
return [
'id' => $this->id ?? '',
'name' => $this->name ?? '',
'city' => $this->city ?? '',
'logo' => $this->logo ?? '',
'seasonCount' => $seasonCount,
'description' => $this->description ?? '',
'isPublic' => $this->isPublic ?? '',
'createdAt' => !empty($this->createdAt) ? $this->createdAt->format('Y-m-d H:i:s') : '',
];
}
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['name']))
{
$this->name = $dataList['name'];
}
if (!empty($dataList['city']))
{
$this->city = $dataList['city'];
}
if (!empty($dataList['logo']))
{
$this->logo = $dataList['logo'];
}
if (!empty($dataList['description']))
{
$this->description = $dataList['description'];
}
if (isset($dataList['matchesBetweenTeams']))
{
$this->matchesBetweenTeams = (int) $dataList['matchesBetweenTeams'];
}
if (isset($dataList['blockedMatchDates']))
{
$this->blockedMatchDates = $dataList['blockedMatchDates'];
}
if (!empty($dataList['seasonList']))
{
foreach ($dataList['seasonList'] as $seasonItem)
{
$seasonDto = new SeasonDto();
$seasonDto->fillFromArray($seasonItem);
$this->seasonDtoList[] = $seasonDto;
}
}
if (isset($dataList['isPublic']))
{
$this->isPublic = (bool) $dataList['isPublic'];
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dataList['createdAt']);
}
}
public function fillFromObject(League $leagueObj): void
{
if ($leagueObj->getId() !== null)
{
$this->id = $leagueObj->getId();
}
if ($leagueObj->getName() !== null)
{
$this->name = $leagueObj->getName();
}
if ($leagueObj->getCity() !== null)
{
$this->city = $leagueObj->getCity();
}
if ($leagueObj->getDescription() !== null)
{
$this->description = $leagueObj->getDescription();
}
if ($leagueObj->getLogo() !== null)
{
$this->logo = $leagueObj->getLogo();
}
if ($leagueObj->isActive() !== null)
{
$this->active = $leagueObj->isActive();
}
if ($leagueObj->getMatchesBetweenTeams() !== null)
{
$this->matchesBetweenTeams = $leagueObj->getMatchesBetweenTeams();
}
if ($leagueObj->getBlockedMatchDates() !== null)
{
$this->blockedMatchDates = $leagueObj->getBlockedMatchDates();
}
if ($leagueObj->getCreatedAt() !== null)
{
$this->createdAt = $leagueObj->getCreatedAt();
}
if ($leagueObj->isPublic() !== null)
{
$this->isPublic = $leagueObj->isPublic();
}
if ($leagueObj->getSeasons() !== null)
{
foreach ($leagueObj->getSeasons() as $seasonObj)
{
$seasonDto = new SeasonDto();
$seasonDto->fillFromEntity($seasonObj);
$this->seasonDtoList[] = $seasonDto;
}
}
}
/**
* @throws ValidationException
*/
public function validate(): void
{
if (empty($this->name))
{
$this->validationErrors[] = 'El nombre no puede estar vacío.';
}
if (empty($this->city))
{
$this->validationErrors[] = 'La localidad no puede estar vacía.';
}
if (!empty($this->validationErrors))
{
throw new ValidationException($this->validationErrors);
}
}
}

137
src/Dto/NotificationDto.php Normal file
View File

@ -0,0 +1,137 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\Notification;
class NotificationDto
{
public static string $TYPE_JOIN_LEAGUE = 'joinLeague';
public static string $TYPE_JOIN_TEAM = 'joinTeam';
public static string $TYPE_CAPTAIN_REQUEST = 'captainRequest';
public int $id;
public string $type;
public string $message;
public int $teamId;
public int $leagueId;
public int $userWhoFiredEventId;
public int $userToNotifyId;
public bool $isRead;
public \DateTimeImmutable $readAt;
public \DateTimeImmutable $createdAt;
public function toArray(): array
{
return [
'id' => $this->id ?? '',
'type' => $this->type ?? '',
'message' => $this->message ?? '',
'teamId' => $this->teamId ?? '',
'leagueId' => $this->leagueId ?? '',
'isRead' => $this->isRead ?? false,
'readAt' => !empty($this->readAt) ? $this->readAt->format('Y-m-d H:i:s') : '',
'createdAt' => !empty($this->createdAt) ? $this->createdAt->format('Y-m-d H:i:s') : ''
];
}
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['type']))
{
$this->type = match($dataList['type']) {
self::$TYPE_JOIN_LEAGUE => 'JOIN_LEAGUE',
self::$TYPE_JOIN_TEAM => 'JOIN_TEAM',
self::$TYPE_CAPTAIN_REQUEST => 'CAPTAIN_REQUEST',
default => null
};
}
if (!empty($dataList['message']))
{
$this->message = $dataList['message'];
}
if (!empty($dataList['isRead']))
{
$this->isRead = $dataList['isRead'];
}
if (!empty($dataList['readAt']))
{
$this->readAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dataList['readAt']);
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dataList['createdAt']);
}
if (isset($dataList['teamId']))
{
$this->teamId = (int) $dataList['teamId'];
}
if (isset($dataList['userWhoFiredEventId']))
{
$this->userWhoFiredEventId = $dataList['userWhoFiredEventId'];
}
if (isset($dataList['userToNotifyId']))
{
$this->userToNotifyId = $dataList['userToNotifyId'];
}
if (isset($dataList['leagueId']))
{
$this->leagueId = $dataList['leagueId'];
}
}
public function fillFromObj(Notification $notificationObj): self
{
if ($notificationObj->getId() !== null)
{
$this->id = $notificationObj->getId();
}
if ($notificationObj->getType() !== null)
{
$this->type = $notificationObj->getType();
}
if ($notificationObj->getMessage() !== null)
{
$this->message = $notificationObj->getMessage();
}
if ($notificationObj->getUserWhoFiredEvent() !== null)
{
$this->userWhoFiredEventId = ($notificationObj->getUserWhoFiredEvent())->getId();
}
if ($notificationObj->getUserToNotify() !== null)
{
$this->userToNotifyId = ($notificationObj->getUserToNotify())->getId();
}
if ($notificationObj->getLeague() !== null)
{
$this->leagueId = ($notificationObj->getLeague())->getId();
}
if ($notificationObj->getTeamId() !== null)
{
$this->teamId = $notificationObj->getTeamId();
}
if ($notificationObj->isIsRead() !== null)
{
$this->isRead = $notificationObj->isIsRead();
}
if ($notificationObj->getReadAt() !== null)
{
$this->readAt = $notificationObj->getReadAt();
}
if ($notificationObj->getCreatedAt() !== null)
{
$this->createdAt = $notificationObj->getCreatedAt();
}
return $this;
}
public function validate(): void
{
}
}

127
src/Dto/PlayerDto.php Normal file
View File

@ -0,0 +1,127 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\Player;
class PlayerDto
{
public int $id;
public string $firstName;
public string $lastName;
public string $position;
public int $jerseyNumber;
public bool $isFederated;
public string $pictureFileName;
public \DateTime $birthday;
public array $fileDtoList;
public TeamDto $teamDto;
public \DateTime $createdAt;
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['firstName']))
{
$this->firstName = $dataList['firstName'];
}
if (!empty($dataList['lastName']))
{
$this->lastName = $dataList['lastName'];
}
if (!empty($dataList['position']))
{
$this->position = $dataList['position'];
}
if (!isset($dataList['jerseyNumber']))
{
$this->jerseyNumber = (int) $dataList['jerseyNumber'];
}
if (isset($dataList['isFederated']))
{
$this->isFederated = (bool) $dataList['isFederated'];
}
if (isset($dataList['pictureFileName']))
{
$this->pictureFileName = $dataList['pictureFileName'];
}
if (!empty($dataList['birthday']))
{
$this->birthday = \DateTime::createFromFormat('Y-m-d', $dataList['birthday']);
}
if (!empty($dataList['fileList']))
{
foreach ($dataList['fileList'] as $fileItem)
{
$fileDto = new FileDto();
$fileDto->fillFromArray($fileItem);
$this->fileDtoList[] = $fileDto;
}
}
if (!empty($dataList['team']))
{
$teamDto = new TeamDto();
$teamDto->fillFromArray($dataList['team']);
$this->teamDto = $teamDto;
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $dataList['createdAt']);
}
}
public function fillFromObject(Player $playerEntity): void
{
if ($playerEntity->getId() !== null)
{
$this->id = $playerEntity->getId();
}
if ($playerEntity->getFirstName() !== null)
{
$this->firstName = $playerEntity->getFirstName();
}
if ($playerEntity->getLastName() !== null)
{
$this->lastName = $playerEntity->getLastName();
}
if ($playerEntity->getBirthday() !== null)
{
$this->birthday = new \DateTime($playerEntity->getBirthday()->format('Y-m-d'),new \DateTimeZone('Europe/Madrid'));
}
if ($playerEntity->getJerseyNumber() !== null)
{
$this->jerseyNumber = $playerEntity->getJerseyNumber();
}
if ($playerEntity->getPosition() !== null)
{
$this->position = $playerEntity->getPosition();
}
if ($playerEntity->getPictureFileName() !== null)
{
$this->pictureFileName = $playerEntity->getPictureFileName();
}
if ($playerEntity->getTeam() !== null)
{
$teamDto = new TeamDto();
$teamDto->fillFromEntity($playerEntity->getTeam());
$this->teamDto = $teamDto;
}
if ($playerEntity->getFiles() !== null)
{
foreach ($playerEntity->getFiles() as $fileEntity)
{
$fileDto = new FileDto();
$fileDto->fillFromObject($fileEntity);
$this->fileDtoList[] = $fileDto;
}
}
}
public function validate(): void
{
}
}

31
src/Dto/SeasonDataDto.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace DMD\LaLigaApi\Dto;
class SeasonDataDto
{
public int $id;
public int $teamId;
public int $points;
public int $seasonId;
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = (int) $dataList['id'];
}
if (isset($dataList['teamId']))
{
$this->teamId = $dataList['teamId'];
}
if (isset($dataList['points']))
{
$this->points = $dataList['points'];
}
if (isset($dataList['seasonId']))
{
$this->seasonId = $dataList['seasonId'];
}
}
}

232
src/Dto/SeasonDto.php Normal file
View File

@ -0,0 +1,232 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\Season;
use DMD\LaLigaApi\Entity\Team;
use DMD\LaLigaApi\Exception\ValidationException;
class SeasonDto
{
public int $id;
public \DateTime $dateStart;
public \DateTime $createdAt;
public array $teamDtoList;
public array $facilityDtoList;
public int $leagueId;
public int $numberOfTeams;
public int $seasonNumber;
public int $gamesPerWeek;
public string $leagueName;
public int $pointsPerWin;
public int $pointsPerLoss;
public int $pointsPerDraw;
public array $gameDtoList;
public array $seasonDataDtoList;
public bool $active;
public array $validationErrors;
public int $matchesBetweenTeams;
public function createSeasonArray(): array
{
$numberOfTeams = $this->numberOfTeams ?? 0;
$teamList = [];
if (!empty($this->teamDtoList))
{
$numberOfTeams = count($this->teamDtoList);
foreach ($this->teamDtoList as $teamDto)
{
$teamList[] = $teamDto->toArray();
}
}
return [
'id' => $this->id ?? null,
'seasonNumber' => $this->seasonNumber ?? null,
'numberOfTeams' => $numberOfTeams,
'gamesPerWeek' => $this->gamesPerWeek ?? null,
'dateStart' => !empty($this->dateStart) ? $this->dateStart->format('Y-m-d'): null,
'leagueId' => $this->leagueId ?? null,
'leagueName' => $this->leagueName ?? null,
'teams' => $teamList,
'pointsPerWin' => $this->pointsPerWin ?? null,
'pointsPerDraw' => $this->pointsPerDraw ?? null,
'pointsPerLoss' => $this->pointsPerLoss ?? null,
'active' => $this->active ?? null
];
}
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = (int) $dataList['id'];
}
if (!empty($dataList['dateStart']))
{
$dateStart = \DateTime::createFromFormat('Y-m-d', $dataList['dateStart']);
if ($dateStart)
{
$this->dateStart = $dateStart;
}
}
if (isset($dataList['gamesPerWeek']))
{
$this->gamesPerWeek = (int) $dataList['gamesPerWeek'];
}
if (isset($dataList['pointsPerWin']))
{
$this->pointsPerWin = (int) $dataList['pointsPerWin'];
}
if (!empty($dataList['pointsPerDraw']))
{
$this->pointsPerDraw = (int) $dataList['pointsPerDraw'];
}
if (isset($dataList['pointsPerLoss']))
{
$this->pointsPerLoss = (int) $dataList['pointsPerLoss'];
}
if (isset($dataList['active']))
{
$this->active = $dataList['active'];
}
if (isset($dataList['numberOfTeams']))
{
$this->numberOfTeams = $dataList['numberOfTeams'];
}
if (isset($dataList['teamList']))
{
foreach ($dataList['teamList'] as $teamName)
{
$teamDto = new TeamDto();
$teamDto->name = $teamName;
$this->teamDtoList[] = $teamDto;
}
}
if (!empty($dataList['facilityList']))
{
foreach ($dataList['facilityList'] as $facilityItem)
{
$facilityDto = new FacilityDto();
$facilityDto->fillFromArray($facilityItem);
$this->facilityDtoList[] = $facilityDto;
}
}
if (isset($dataList['gameList']))
{
foreach ($dataList['gameList'] as $gameItem)
{
$gameDto = new GameDto();
$gameDto->fillFromArray($gameItem);
$this->gameDtoList[] = $gameDto;
}
}
}
public function fillFromEntity(Season $seasonEntity): void
{
if ($seasonEntity->getId() !== null)
{
$this->id = $seasonEntity->getId();
}
if ($seasonEntity->getDateStart() !== null)
{
$this->dateStart = $seasonEntity->getDateStart();
}
$leagueObj = $seasonEntity->getLeague();
if ($leagueObj !== null)
{
$this->leagueId = $leagueObj->getId();
$this->leagueName = $leagueObj->getName();
}
if ($seasonEntity->isActive() !== null)
{
$this->active = $seasonEntity->isActive();
}
if ($seasonEntity->getTeams())
{
foreach ($seasonEntity->getTeams() as $teamEntity)
{
$teamDto = new TeamDto();
$teamDto->fillFromEntity($teamEntity);
$this->teamDtoList[] = $teamDto;
}
}
if ($seasonEntity->getFacilities())
{
foreach ($seasonEntity->getFacilities() as $facilityEntity)
{
$facilityDto = new FacilityDto();
$facilityDto->fillFromEntity($facilityEntity);
$this->facilityDtoList[] = $facilityDto;
}
}
if ($seasonEntity->getGames())
{
foreach ($seasonEntity->getGames() as $gameEntity)
{
$gameDto = new GameDto();
$gameDto->fillFromObject($gameEntity);
$this->gameDtoList[] = $gameDto;
}
}
if ($seasonEntity->getCreatedAt())
{
$this->createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $seasonEntity->getCreatedAt()->format('Y-m-d H:i:s'));
}
if ($seasonEntity->getPointsPerWin())
{
$this->pointsPerWin = $seasonEntity->getPointsPerWin();
}
if ($seasonEntity->getPointsPerLoss())
{
$this->pointsPerLoss = $seasonEntity->getPointsPerLoss();
}
if ($seasonEntity->getPointsPerDraw())
{
$this->pointsPerDraw = $seasonEntity->getPointsPerDraw();
}
if ($seasonEntity->getGamesPerWeek())
{
$this->gamesPerWeek = $seasonEntity->getGamesPerWeek();
}
if ($seasonEntity->isActive())
{
$this->active = $seasonEntity->isActive();
}
}
/**
* @throws ValidationException
*/
public function validate(): void
{
if (empty($this->pointsPerWin))
{
$this->validationErrors[] = 'Los puntos por partido ganado no pueden estar vacíos.';
}
if (
isset($this->pointsPerDraw, $this->pointsPerWin, $this->pointsPerLoss) &&
(($this->pointsPerWin <= $this->pointsPerDraw) ||
($this->pointsPerWin <= $this->pointsPerLoss))
)
{
$this->validationErrors[] = 'Los puntos por partido ganado deben ser superiores a los puntos por empate y por perdida.';
}
if (isset($this->pointsPerDraw, $this->pointsPerWin) && ($this->pointsPerDraw > $this->pointsPerWin))
{
$this->validationErrors[] = 'Los puntos por empate deben ser inferiores a los puntos por partido ganado.';
}
if (isset($this->pointsPerDraw, $this->pointsPerLoss) && ($this->pointsPerDraw > 0) && ($this->pointsPerDraw < $this->pointsPerLoss))
{
$this->validationErrors[] = 'Los puntos por empate deben ser superiores a los puntos por partido perdido.';
}
if (isset($this->pointsPerDraw, $this->pointsPerWin, $this->pointsPerLoss) && ($this->pointsPerWin + $this->pointsPerDraw + $this->pointsPerLoss > 20))
{
$this->validationErrors[] = 'La suma de los puntos por partidos ganados, perdidos y empatados no puede ser superior a 20.';
}
if (!empty($this->validationErrors))
{
throw new ValidationException($this->validationErrors);
}
}
}

141
src/Dto/TeamDto.php Normal file
View File

@ -0,0 +1,141 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\Facility;
use DMD\LaLigaApi\Entity\Team;
use DMD\LaLigaApi\Exception\ValidationException;
class TeamDto
{
public int $id;
public string $name;
public string $dayOfWeekForHomeGame;
public string $logo;
public bool $active;
public int $leagueId;
public array $seasonDtoList;
public array $playerDtoList;
public \DateTimeImmutable $createdAt;
public UserDto $captainDto;
public array $validationErrors;
public function toArray(): array
{
return [
'id' => $this->id ?? '',
'name' => $this->name ?? '',
'dayOfWeekForHomeGame' => $this->dayOfWeekForHomeGame ?? '',
'logo' => $this->logo ?? '',
'captainName'=> isset($this->captainDto) ? $this->captainDto->firstName . ' ' . $this->captainDto->lastName : 'No asignado',
'captainId'=> isset($this->captainDto) ? $this->captainDto->id : 'No asignado',
];
}
public function fillFromArray(array $dataList): void
{
if (isset($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['name']))
{
$this->name = $dataList['name'];
}
if (!empty($dataList['dayOfWeekForHomeGame']))
{
$this->dayOfWeekForHomeGame = $dataList['dayOfWeekForHomeGame'];
}
if (isset($dataList['active']))
{
$this->active = $dataList['active'];
}
if (isset($dataList['logo']))
{
$this->logo = $dataList['logo'];
}
if (isset($dataList['leagueId']))
{
$this->leagueId = (int) $dataList['leagueId'];
}
if (!empty($dataList['seasonList']))
{
foreach ($dataList['seasonList'] as $seasonItem)
{
$seasonDto = new SeasonDto();
$seasonDto->fillFromArray($seasonItem);
$this->seasonDtoList[] = $seasonDto;
}
}
if (!empty($dataList['playerList']))
{
foreach ($dataList['playerList'] as $playerItem)
{
$playerDto = new PlayerDto();
$playerDto->fillFromArray($playerItem);
$this->playerDtoList[] = $playerDto;
}
}
if (!empty($dataList['captain']))
{
$captainDto = new UserDto();
$captainDto->fillFromArray($dataList['captain']);
$this->captainDto = $captainDto;
}
if (!empty($dataList['createdAt']))
{
$this->createdAt = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dataList['createdAt'], new \DateTimeZone('Europe/Madrid'));
}
}
public function fillFromEntity(Team $teamEntity): void
{
if ($teamEntity->getId())
{
$this->id = $teamEntity->getId();
}
if ($teamEntity->getName())
{
$this->name = $teamEntity->getName();
}
if ($teamEntity->getDayOfTheWeekForHomeGame())
{
$this->dayOfWeekForHomeGame = $teamEntity->getDayOfTheWeekForHomeGame();
}
if ($teamEntity->getPlayers())
{
foreach ($teamEntity->getPlayers() as $playerEntity)
{
$playerDto = new PlayerDto();
$playerDto->fillFromObject($playerEntity);
$this->playerDtoList[] = $playerDto;
}
}
if ($teamEntity->getTeamLogo())
{
$this->logo = $teamEntity->getTeamLogo();
}
if ($teamEntity->getCaptain())
{
$this->captainDto = new UserDto;
$this->captainDto->fillFromObject($teamEntity->getCaptain());
}
if ($teamEntity->getCreatedAt())
{
$this->createdAt = $teamEntity->getCreatedAt();
}
}
public function validate(): void
{
if (empty($this->name))
{
$this->validationErrors[] = 'El nombre del equipo no puede estar vacío.';
}
if (!empty($this->validationErrors))
{
throw new ValidationException($this->validationErrors);
}
}
}

217
src/Dto/UserDto.php Normal file
View File

@ -0,0 +1,217 @@
<?php
namespace DMD\LaLigaApi\Dto;
use DMD\LaLigaApi\Entity\User;
class UserDto
{
public int $id;
public array $roles;
public string $email;
public string $password;
public string $firstName;
public string $lastName;
public string $phone;
public string $profilePicture;
public \DateTimeInterface $birthday;
public array $noteList;
public bool $privacyPolicy;
public bool $active;
public array $receivedNotificationDtoList;
public array $validationErrors;
public function toArray(): array
{
if (!empty($this->receivedNotificationDtoList))
{
foreach ($this->receivedNotificationDtoList as $notificationDto)
{
$notificationArray[] = $notificationDto->toArray();
}
}
return [
'id' => $this->id ?? null,
'email' => $this->email ?? null,
'firstName' => $this->firstName ?? null,
'lastName' => $this->lastName ?? null,
'phone' => $this->phone,
'profilePicture' => $this->profilePicture ?? null,
'birthday' => $this->birthday->format('Y-m-d'),
'noteList' => $this->noteList ?? [],
'notificationList' => $notificationArray ?? []
];
}
public function toLoginArray(): array
{
return [
'id' => $this->id ?? null,
'email' => $this->email ?? null,
'firstName' => $this->firstName ?? null,
'lastName' => $this->lastName ?? null,
'phone' => $this->phone,
'profilePicture' => $this->profilePicture ?? null,
'birthday' => $this->birthday->format('Y-m-d'),
'unreadNotifications' => count($this->receivedNotificationDtoList)
];
}
public function toRegisterArray(): array
{
return [
'id' => $this->id ?? null,
'email' => $this->email ?? null,
'firstName' => $this->firstName ?? null,
'lastName' => $this->lastName ?? null,
'phone' => $this->phone,
'profilePicture' => $this->profilePicture ?? null,
'birthday' => $this->birthday->format('Y-m-d'),
];
}
public function fillFromObject(User $userObj): void
{
if ($userObj->getId() !== null)
{
$this->id = $userObj->getId();
}
if ($userObj->getEmail() !== null)
{
$this->email = $userObj->getEmail();
}
if ($userObj->getFirstName() !== null)
{
$this->firstName = $userObj->getFirstName();
}
if ($userObj->getLastName() !== null)
{
$this->lastName = $userObj->getLastName();
}
if ($userObj->getPhone() !== null)
{
$this->phone = $userObj->getPhone();
}
if ($userObj->isPrivacyPolicy() !== null)
{
$this->privacyPolicy = $userObj->isPrivacyPolicy();
}
if ($userObj->getProfilePicture() !== null)
{
$this->profilePicture = $userObj->getProfilePicture();
}
if ($userObj->getBirthday() !== null)
{
$this->birthday = $userObj->getBirthday();
}
if ($userObj->getReceivedNotifications() !== null)
{
foreach ($userObj->getReceivedNotifications() as $receivedNotificationEntity)
{
$notificationDto = new NotificationDto();
$notificationDto->fillFromObj($receivedNotificationEntity);
$this->receivedNotificationDtoList[] = $notificationDto;
}
}
if ($userObj->getNoteList() !== null)
{
$this->noteList = $userObj->getNoteList();
}
}
public function fillFromArray(array $dataList): void
{
if (!empty($dataList['id']))
{
$this->id = $dataList['id'];
}
if (!empty($dataList['email']))
{
$this->email = trim($dataList['email']);
}
if (!empty($dataList['password']))
{
$this->password = trim($dataList['password']);
}
if (!empty($dataList['firstName']))
{
$this->firstName = $dataList['firstName'];
}
if (!empty($dataList['lastName']))
{
$this->lastName = $dataList['lastName'];
}
if (!empty($dataList['phone']))
{
$this->phone = $dataList['phone'];
}
if (!empty($dataList['profilePicture']))
{
$this->profilePicture = $dataList['profilePicture'];
}
if (!empty($dataList['birthday']))
{
$this->birthday = \DateTime::createFromFormat('Y-m-d', $dataList['birthday']);
}
if (!empty($dataList['notes']))
{
$this->noteList = $dataList['notes'];
}
if (isset($dataList['active']))
{
$this->active = $dataList['active'];
}
if (isset($dataList['privacyPolicy']))
{
$this->privacyPolicy = $dataList['privacyPolicy'];
}
}
public function validate(): void
{
if (empty($this->email))
{
$this->validationErrors[] = 'El correo no puede estar vacío.';
}
if (!empty($this->email) && !(filter_var($this->email, FILTER_VALIDATE_EMAIL)))
{
$this->validationErrors[] = 'El correo no está en un formato válido.';
}
if (empty($this->firstName))
{
$this->validationErrors[] = 'El nombre no puede estar vacío';
}
if (empty($this->lastName))
{
$this->validationErrors[] = 'El apellido no puede estar vacío';
}
if (empty($this->privacyPolicy))
{
$this->validationErrors[] = 'No puedes crear cuenta sin aceptar los términos y condiciones';
}
if (!$this->privacyPolicy)
{
$this->validationErrors[] = 'No puedes crear cuenta sin aceptar los términos y condiciones';
}
if (strlen($this->phone) !== 9)
{
$this->validationErrors[] = 'El número de teléfono debe tener 9 dígitos.';
}
if (!preg_match('@[A-Z]@', $this->password))
{
$this->validationErrors[] = 'La contraseña debe contener al menos una letra mayúscula.';
}
if (!preg_match('@[0-9]@', $this->password))
{
$this->validationErrors[] = 'La contraseña debe contener al menos un número.';
}
if (!preg_match('@\W@', $this->password))
{
$this->validationErrors[] = 'La contraseña debe contener al menos un caracter especial.';
}
if (strlen($this->password) < 8)
{
$this->validationErrors[] = 'La contraseña debe contener al menos 8 caracteres.';
}
}
}

0
src/Entity/.gitignore vendored Normal file
View File

96
src/Entity/CustomRole.php Normal file
View File

@ -0,0 +1,96 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\CustomRoleRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CustomRoleRepository::class)]
#[ORM\HasLifecycleCallbacks]
class CustomRole
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\ManyToOne(inversedBy: 'customRoles')]
private ?User $user = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(nullable: true)]
private ?int $entityId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $entityName = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): static
{
$this->createdAt = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Madrid'));
return $this;
}
public function getEntityId(): ?int
{
return $this->entityId;
}
public function setEntityId(?int $entityId): static
{
$this->entityId = $entityId;
return $this;
}
public function getEntityName(): ?string
{
return $this->entityName;
}
public function setEntityName(?string $entityName): static
{
$this->entityName = $entityName;
return $this;
}
}

186
src/Entity/Facility.php Normal file
View File

@ -0,0 +1,186 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\FacilityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: FacilityRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Facility
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $address = null;
#[ORM\OneToMany(mappedBy: 'facility', targetEntity: Game::class)]
private Collection $games;
#[ORM\ManyToOne(inversedBy: 'facilities')]
private ?Season $season = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(nullable: true)]
private ?bool $active = null;
#[ORM\Column(nullable: true)]
private ?array $availableHours = null;
#[ORM\OneToMany(mappedBy: 'homeFacility', targetEntity: Team::class)]
private Collection $teams;
public function __construct()
{
$this->games = new ArrayCollection();
$this->teams = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): static
{
$this->address = $address;
return $this;
}
/**
* @return Collection<int, Game>
*/
public function getGames(): Collection
{
return $this->games;
}
public function addGame(Game $game): static
{
if (!$this->games->contains($game)) {
$this->games->add($game);
$game->setFacility($this);
}
return $this;
}
public function removeGame(Game $game): static
{
if ($this->games->removeElement($game)) {
// set the owning side to null (unless already changed)
if ($game->getFacility() === $this) {
$game->setFacility(null);
}
}
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): static
{
$this->season = $season;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$timezone = new \DateTimeZone('Europe/Madrid');
$this->createdAt = new \DateTimeImmutable('now', $timezone);
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(?bool $active): static
{
$this->active = $active;
return $this;
}
public function getAvailableHours(): ?array
{
return $this->availableHours;
}
public function setAvailableHours(?array $availableHours): static
{
$this->availableHours = $availableHours;
return $this;
}
/**
* @return Collection<int, Team>
*/
public function getTeams(): Collection
{
return $this->teams;
}
public function addTeam(Team $team): static
{
if (!$this->teams->contains($team)) {
$this->teams->add($team);
$team->setHomeFacility($this);
}
return $this;
}
public function removeTeam(Team $team): static
{
if ($this->teams->removeElement($team)) {
// set the owning side to null (unless already changed)
if ($team->getHomeFacility() === $this) {
$team->setHomeFacility(null);
}
}
return $this;
}
}

111
src/Entity/File.php Normal file
View File

@ -0,0 +1,111 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\FileRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: FileRepository::class)]
#[ORM\HasLifecycleCallbacks]
class File
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\ManyToOne(inversedBy: 'files')]
private ?Game $game = null;
#[ORM\ManyToOne(inversedBy: 'files')]
private ?Player $player = null;
#[ORM\ManyToOne(inversedBy: 'files')]
private ?Season $season = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$timezone = new \DateTimeZone('Europe/Madrid');
$this->createdAt = new \DateTimeImmutable('now', $timezone);
}
public function getGame(): ?Game
{
return $this->game;
}
public function setGame(?Game $game): static
{
$this->game = $game;
return $this;
}
public function getPlayer(): ?Player
{
return $this->player;
}
public function setPlayer(?Player $player): static
{
$this->player = $player;
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): static
{
$this->season = $season;
return $this;
}
}

227
src/Entity/Game.php Normal file
View File

@ -0,0 +1,227 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\GameRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: GameRepository::class)]
class Game
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
private ?int $pointsHome = null;
#[ORM\Column(nullable: true)]
private ?int $pointsAway = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $plannedDate = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $gameDateTime = null;
#[ORM\Column(length: 350, nullable: true)]
private ?string $notes = null;
#[ORM\OneToMany(mappedBy: 'game', targetEntity: File::class)]
private Collection $files;
#[ORM\ManyToOne(inversedBy: 'games')]
private ?Season $season = null;
#[ORM\ManyToOne(inversedBy: 'games')]
private ?Facility $facility = null;
#[ORM\ManyToOne]
private ?Team $homeTeam = null;
#[ORM\ManyToOne]
private ?Team $awayTeam = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updatedAt = null;
public function __construct()
{
$this->files = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getPointsHome(): ?int
{
return $this->pointsHome;
}
public function setPointsHome(?int $pointsHome): static
{
$this->pointsHome = $pointsHome;
return $this;
}
public function getPointsAway(): ?int
{
return $this->pointsAway;
}
public function setPointsAway(?int $pointsAway): static
{
$this->pointsAway = $pointsAway;
return $this;
}
public function getPlannedDate(): ?\DateTimeInterface
{
return $this->plannedDate;
}
public function setPlannedDate(?\DateTimeInterface $plannedDate): static
{
$this->plannedDate = $plannedDate;
return $this;
}
public function getGameDateTime(): ?\DateTimeInterface
{
return $this->gameDateTime;
}
public function setGameDateTime(?\DateTimeInterface $gameDateTime): static
{
$this->gameDateTime = $gameDateTime;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): static
{
$this->notes = $notes;
return $this;
}
/**
* @return Collection<int, File>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(File $file): static
{
if (!$this->files->contains($file)) {
$this->files->add($file);
$file->setGame($this);
}
return $this;
}
public function removeFile(File $file): static
{
if ($this->files->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getGame() === $this) {
$file->setGame(null);
}
}
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): static
{
$this->season = $season;
return $this;
}
public function getFacility(): ?Facility
{
return $this->facility;
}
public function setFacility(?Facility $facility): static
{
$this->facility = $facility;
return $this;
}
public function getHomeTeam(): ?Team
{
return $this->homeTeam;
}
public function setHomeTeam(?Team $homeTeam): static
{
$this->homeTeam = $homeTeam;
return $this;
}
public function getAwayTeam(): ?Team
{
return $this->awayTeam;
}
public function setAwayTeam(?Team $awayTeam): static
{
$this->awayTeam = $awayTeam;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): static
{
$this->createdAt = new \DateTimeImmutable('now');
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
}

199
src/Entity/League.php Normal file
View File

@ -0,0 +1,199 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\LeagueRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: LeagueRepository::class)]
#[ORM\HasLifecycleCallbacks]
class League
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $logo = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $description = null;
#[ORM\Column(nullable: true)]
private ?bool $active = null;
#[ORM\OneToMany(mappedBy: 'league', targetEntity: Season::class)]
private Collection $seasons;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $city = null;
#[ORM\Column(nullable: true)]
private ?int $matchesBetweenTeams = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $blockedMatchDates = null;
#[ORM\Column(nullable: true)]
private ?bool $isPublic = null;
public function __construct()
{
$this->seasons = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): static
{
$this->logo = $logo;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(?bool $active): static
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, Season>
*/
public function getSeasons(): Collection
{
return $this->seasons;
}
public function addSeason(Season $season): static
{
if (!$this->seasons->contains($season)) {
$this->seasons->add($season);
$season->setLeague($this);
}
return $this;
}
public function removeSeason(Season $season): static
{
if ($this->seasons->removeElement($season)) {
// set the owning side to null (unless already changed)
if ($season->getLeague() === $this) {
$season->setLeague(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$timezone = new \DateTimeZone('Europe/Madrid');
$this->createdAt = new \DateTimeImmutable('now', $timezone);
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): static
{
$this->city = $city;
return $this;
}
public function getMatchesBetweenTeams(): ?int
{
return $this->matchesBetweenTeams;
}
public function setMatchesBetweenTeams(?int $matchesBetweenTeams): static
{
$this->matchesBetweenTeams = $matchesBetweenTeams;
return $this;
}
public function getBlockedMatchDates(): ?array
{
return $this->blockedMatchDates;
}
public function setBlockedMatchDates(?array $blockedMatchDates): static
{
$this->blockedMatchDates = $blockedMatchDates;
return $this;
}
public function isPublic(): ?bool
{
return $this->isPublic;
}
public function setIsPublic(?bool $isPublic): static
{
$this->isPublic = $isPublic;
return $this;
}
}

82
src/Entity/Log.php Normal file
View File

@ -0,0 +1,82 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\LogRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: LogRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Log
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $payload = null;
#[ORM\Column(nullable: true)]
private ?int $code = null;
#[ORM\Column(length: 550, nullable: true)]
private ?string $message = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
public function getId(): ?int
{
return $this->id;
}
public function getPayload(): ?string
{
return $this->payload;
}
public function setPayload(?string $payload): static
{
$this->payload = $payload;
return $this;
}
public function getCode(): ?int
{
return $this->code;
}
public function setCode(?int $code): static
{
$this->code = $code;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): static
{
$this->message = $message;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$timezone = new \DateTimeZone('Europe/Madrid');
$this->createdAt = new \DateTimeImmutable('now', $timezone);
}
}

160
src/Entity/Notification.php Normal file
View File

@ -0,0 +1,160 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\NotificationRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NotificationRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Notification
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\ManyToOne(inversedBy: 'requestsSent')]
private ?User $userWhoFiredEvent = null;
#[ORM\Column(length: 280, nullable: true)]
private ?string $message = null;
#[ORM\ManyToOne(inversedBy: 'notifications')]
private ?League $league = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(nullable: true)]
private ?int $teamId = null;
#[ORM\ManyToOne(inversedBy: 'receivedNotifications')]
#[ORM\JoinColumn(nullable: false)]
private ?User $userToNotify = null;
#[ORM\Column(nullable: true)]
private ?bool $isRead = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $readAt = null;
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getUserWhoFiredEvent(): ?User
{
return $this->userWhoFiredEvent;
}
public function setUserWhoFiredEvent(?User $userWhoFiredEvent): static
{
$this->userWhoFiredEvent = $userWhoFiredEvent;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): static
{
$this->message = $message;
return $this;
}
public function getLeague(): ?League
{
return $this->league;
}
public function setLeague(?League $league): static
{
$this->league = $league;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
/**
* @throws \Exception
*/
#[ORM\PrePersist]
public function setCreatedAt(): static
{
$this->createdAt = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Madrid'));
return $this;
}
public function getTeamId(): ?int
{
return $this->teamId;
}
public function setTeamId(?int $teamId): static
{
$this->teamId = $teamId;
return $this;
}
public function getUserToNotify(): ?User
{
return $this->userToNotify;
}
public function setUserToNotify(?User $userToNotify): static
{
$this->userToNotify = $userToNotify;
return $this;
}
public function isIsRead(): ?bool
{
return $this->isRead;
}
public function setIsRead(?bool $isRead): static
{
$this->isRead = $isRead;
return $this;
}
public function getReadAt(): ?\DateTimeImmutable
{
return $this->readAt;
}
public function setReadAt(?\DateTimeImmutable $readAt): static
{
$this->readAt = $readAt;
return $this;
}
}

181
src/Entity/Player.php Normal file
View File

@ -0,0 +1,181 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\PlayerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PlayerRepository::class)]
class Player
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $firstName = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $lastName = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $position = null;
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
private ?int $jerseyNumber = null;
#[ORM\Column(nullable: true)]
private ?bool $isFederated = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $pictureFileName = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $birthday = null;
#[ORM\OneToMany(mappedBy: 'player', targetEntity: File::class)]
private Collection $files;
#[ORM\ManyToOne(inversedBy: 'players')]
private ?Team $team = null;
public function __construct()
{
$this->files = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): static
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): static
{
$this->lastName = $lastName;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(?string $position): static
{
$this->position = $position;
return $this;
}
public function getJerseyNumber(): ?int
{
return $this->jerseyNumber;
}
public function setJerseyNumber(?int $jerseyNumber): static
{
$this->jerseyNumber = $jerseyNumber;
return $this;
}
public function isIsFederated(): ?bool
{
return $this->isFederated;
}
public function setIsFederated(?bool $isFederated): static
{
$this->isFederated = $isFederated;
return $this;
}
public function getPictureFileName(): ?string
{
return $this->pictureFileName;
}
public function setPictureFileName(?string $pictureFileName): static
{
$this->pictureFileName = $pictureFileName;
return $this;
}
public function getBirthday(): ?\DateTimeInterface
{
return $this->birthday;
}
public function setBirthday(?\DateTimeInterface $birthday): static
{
$this->birthday = $birthday;
return $this;
}
/**
* @return Collection<int, File>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(File $file): static
{
if (!$this->files->contains($file)) {
$this->files->add($file);
$file->setPlayer($this);
}
return $this;
}
public function removeFile(File $file): static
{
if ($this->files->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getPlayer() === $this) {
$file->setPlayer(null);
}
}
return $this;
}
public function getTeam(): ?Team
{
return $this->team;
}
public function setTeam(?Team $team): static
{
$this->team = $team;
return $this;
}
}

293
src/Entity/Season.php Normal file
View File

@ -0,0 +1,293 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\SeasonRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SeasonRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Season
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $dateStart = null;
#[ORM\Column(nullable: true)]
private ?bool $active = null;
#[ORM\ManyToMany(targetEntity: Team::class, inversedBy: 'seasons')]
private Collection $teams;
#[ORM\ManyToOne(inversedBy: 'seasons')]
private ?League $league = null;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Game::class)]
private Collection $games;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Facility::class)]
private Collection $facilities;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $updatedAt = null;
#[ORM\OneToMany(mappedBy: 'season', targetEntity: File::class)]
private Collection $files;
#[ORM\Column(nullable: true)]
private ?int $pointsPerWin = null;
#[ORM\Column(nullable: true)]
private ?int $pointsPerDraw = null;
#[ORM\Column(nullable: true)]
private ?int $pointsPerLoss = null;
#[ORM\Column(nullable: true)]
private ?int $gamesPerWeek = null;
public function __construct()
{
$this->teams = new ArrayCollection();
$this->games = new ArrayCollection();
$this->facilities = new ArrayCollection();
$this->files = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Team>
*/
public function getTeams(): Collection
{
return $this->teams;
}
public function addTeam(Team $team): static
{
if (!$this->teams->contains($team)) {
$this->teams->add($team);
}
return $this;
}
public function removeTeam(Team $team): static
{
$this->teams->removeElement($team);
return $this;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateStart(\DateTimeInterface $dateStart): static
{
$this->dateStart = $dateStart;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(?bool $active): static
{
$this->active = $active;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$timezone = new \DateTimeZone('Europe/Madrid');
$this->createdAt = new \DateTimeImmutable('now', $timezone);
}
public function getLeague(): ?League
{
return $this->league;
}
public function setLeague(?League $league): static
{
$this->league = $league;
return $this;
}
/**
* @return Collection<int, Game>
*/
public function getGames(): Collection
{
return $this->games;
}
public function addGame(Game $game): static
{
if (!$this->games->contains($game)) {
$this->games->add($game);
$game->setSeason($this);
}
return $this;
}
public function removeGame(Game $game): static
{
if ($this->games->removeElement($game)) {
// set the owning side to null (unless already changed)
if ($game->getSeason() === $this) {
$game->setSeason(null);
}
}
return $this;
}
/**
* @return Collection<int, Facility>
*/
public function getFacilities(): Collection
{
return $this->facilities;
}
public function addFacility(Facility $facility): static
{
if (!$this->facilities->contains($facility)) {
$this->facilities->add($facility);
$facility->setSeason($this);
}
return $this;
}
public function removeFacility(Facility $facility): static
{
if ($this->facilities->removeElement($facility)) {
// set the owning side to null (unless already changed)
if ($facility->getSeason() === $this) {
$facility->setSeason(null);
}
}
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection<int, File>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(File $file): static
{
if (!$this->files->contains($file)) {
$this->files->add($file);
$file->setSeason($this);
}
return $this;
}
public function removeFile(File $file): static
{
if ($this->files->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getSeason() === $this) {
$file->setSeason(null);
}
}
return $this;
}
public function getPointsPerWin(): ?int
{
return $this->pointsPerWin;
}
public function setPointsPerWin(?int $pointsPerWin): static
{
$this->pointsPerWin = $pointsPerWin;
return $this;
}
public function getPointsPerDraw(): ?int
{
return $this->pointsPerDraw;
}
public function setPointsPerDraw(?int $pointsPerDraw): static
{
$this->pointsPerDraw = $pointsPerDraw;
return $this;
}
public function getPointsPerLoss(): ?int
{
return $this->pointsPerLoss;
}
public function setPointsPerLoss(?int $pointsPerLoss): static
{
$this->pointsPerLoss = $pointsPerLoss;
return $this;
}
public function getGamesPerWeek(): ?int
{
return $this->gamesPerWeek;
}
public function setGamesPerWeek(?int $gamesPerWeek): static
{
$this->gamesPerWeek = $gamesPerWeek;
return $this;
}
}

78
src/Entity/SeasonData.php Normal file
View File

@ -0,0 +1,78 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\SeasonDataRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SeasonDataRepository::class)]
class SeasonData
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'seasonData')]
private ?Team $team = null;
#[ORM\Column(nullable: true)]
private ?int $points = null;
#[ORM\ManyToOne(inversedBy: 'seasonData')]
private ?Season $season = null;
public function __construct()
{
}
public function getId(): ?int
{
return $this->id;
}
public function getTeam(): ?Team
{
return $this->team;
}
public function setTeam(?Team $team): static
{
$this->team = $team;
return $this;
}
public function getPoints(): ?int
{
return $this->points;
}
public function setSeasonPoints(?int $points): static
{
$this->points = $points;
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): static
{
$this->season = $season;
return $this;
}
public function setPoints(?int $points): static
{
$this->points = $points;
return $this;
}
}

247
src/Entity/Team.php Normal file
View File

@ -0,0 +1,247 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\TeamRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: TeamRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Team
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(nullable: true)]
private ?bool $active = null;
#[ORM\ManyToMany(targetEntity: Season::class, mappedBy: 'teams')]
private Collection $seasons;
#[ORM\OneToMany(mappedBy: 'team', targetEntity: SeasonData::class)]
private Collection $seasonData;
#[ORM\OneToMany(mappedBy: 'team', targetEntity: Player::class)]
private Collection $players;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\OneToOne(inversedBy: 'team', cascade: ['persist', 'remove'])]
private ?User $captain = null;
#[ORM\ManyToOne(inversedBy: 'teams')]
private ?Facility $homeFacility = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $dayOfTheWeekForHomeGame = null;
#[ORM\Column(nullable: true)]
private ?int $leagueId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $teamLogo = null;
public function __construct()
{
$this->seasons = new ArrayCollection();
$this->seasonData = new ArrayCollection();
$this->players = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(?bool $active): static
{
$this->active = $active;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$this->createdAt = new \DateTimeImmutable();
}
/**
* @return Collection<int, Season>
*/
public function getSeasons(): Collection
{
return $this->seasons;
}
public function addSeason(Season $season): static
{
if (!$this->seasons->contains($season)) {
$this->seasons->add($season);
$season->addTeam($this);
}
return $this;
}
public function removeSeason(Season $season): static
{
if ($this->seasons->removeElement($season)) {
$season->removeTeam($this);
}
return $this;
}
/**
* @return Collection<int, SeasonData>
*/
public function getSeasonData(): Collection
{
return $this->seasonData;
}
public function addSeasonData(SeasonData $seasonData): static
{
if (!$this->seasonData->contains($seasonData)) {
$this->seasonData->add($seasonData);
$seasonData->setTeam($this);
}
return $this;
}
public function removeSeasonData(SeasonData $seasonData): static
{
if ($this->seasonData->removeElement($seasonData)) {
// set the owning side to null (unless already changed)
if ($seasonData->getTeam() === $this) {
$seasonData->setTeam(null);
}
}
return $this;
}
/**
* @return Collection<int, Player>
*/
public function getPlayers(): Collection
{
return $this->players;
}
public function addPlayer(Player $player): static
{
if (!$this->players->contains($player)) {
$this->players->add($player);
$player->setTeam($this);
}
return $this;
}
public function removePlayer(Player $player): static
{
if ($this->players->removeElement($player)) {
// set the owning side to null (unless already changed)
if ($player->getTeam() === $this) {
$player->setTeam(null);
}
}
return $this;
}
public function getCaptain(): ?User
{
return $this->captain;
}
public function setCaptain(?User $captain): static
{
$this->captain = $captain;
return $this;
}
public function getHomeFacility(): ?Facility
{
return $this->homeFacility;
}
public function setHomeFacility(?Facility $homeFacility): static
{
$this->homeFacility = $homeFacility;
return $this;
}
public function getDayOfTheWeekForHomeGame(): ?string
{
return $this->dayOfTheWeekForHomeGame;
}
public function setDayOfTheWeekForHomeGame(?string $dayOfTheWeekForHomeGame): static
{
$this->dayOfTheWeekForHomeGame = $dayOfTheWeekForHomeGame;
return $this;
}
public function getLeagueId(): ?int
{
return $this->leagueId;
}
public function setLeagueId(?int $leagueId): static
{
$this->leagueId = $leagueId;
return $this;
}
public function getTeamLogo(): ?string
{
return $this->teamLogo;
}
public function setTeamLogo(?string $teamLogo): static
{
$this->teamLogo = $teamLogo;
return $this;
}
}

Some files were not shown because too many files have changed in this diff Show More