From 924d495141062f7d734b542827976433c3729334 Mon Sep 17 00:00:00 2001 From: "Chuck.D.Norris" <boveoriol@gmail.com> Date: Thu, 14 Nov 2024 15:46:00 +0100 Subject: [PATCH 1/9] feat(contract): add Contract Introduce a new Contract MVC for managing Contracts. Modify the element table to meet the updated requirements, ensuring proper data handling and integrity. --- docker/database/start-scripts/0-init.sql | 10 + src/app/Controllers/ContractController.php | 20 + src/app/Layouts/MainLayout.php | 2 +- src/app/Models/Contract.php | 190 +++++++ src/app/Views/Contracts.php | 26 + src/routes/web.php | 7 +- src/vendor/autoload.php | 25 + src/vendor/composer/ClassLoader.php | 579 ++++++++++++++++++++ src/vendor/composer/InstalledVersions.php | 359 ++++++++++++ src/vendor/composer/LICENSE | 21 + src/vendor/composer/autoload_classmap.php | 15 + src/vendor/composer/autoload_files.php | 12 + src/vendor/composer/autoload_namespaces.php | 9 + src/vendor/composer/autoload_psr4.php | 16 + src/vendor/composer/autoload_real.php | 50 ++ src/vendor/composer/autoload_static.php | 89 +++ src/vendor/composer/installed.json | 484 ++++++++++++++++ src/vendor/composer/installed.php | 77 +++ src/vendor/composer/platform_check.php | 26 + src/vendor/graham-campbell/result-type | 1 + src/vendor/phpoption/phpoption | 1 + src/vendor/symfony/polyfill-ctype | 1 + src/vendor/symfony/polyfill-mbstring | 1 + src/vendor/symfony/polyfill-php80 | 1 + src/vendor/vlucas/phpdotenv | 1 + 25 files changed, 2019 insertions(+), 4 deletions(-) create mode 100644 src/app/Controllers/ContractController.php create mode 100644 src/app/Models/Contract.php create mode 100644 src/app/Views/Contracts.php create mode 100644 src/vendor/autoload.php create mode 100644 src/vendor/composer/ClassLoader.php create mode 100644 src/vendor/composer/InstalledVersions.php create mode 100644 src/vendor/composer/LICENSE create mode 100644 src/vendor/composer/autoload_classmap.php create mode 100644 src/vendor/composer/autoload_files.php create mode 100644 src/vendor/composer/autoload_namespaces.php create mode 100644 src/vendor/composer/autoload_psr4.php create mode 100644 src/vendor/composer/autoload_real.php create mode 100644 src/vendor/composer/autoload_static.php create mode 100644 src/vendor/composer/installed.json create mode 100644 src/vendor/composer/installed.php create mode 100644 src/vendor/composer/platform_check.php create mode 160000 src/vendor/graham-campbell/result-type create mode 160000 src/vendor/phpoption/phpoption create mode 160000 src/vendor/symfony/polyfill-ctype create mode 160000 src/vendor/symfony/polyfill-mbstring create mode 160000 src/vendor/symfony/polyfill-php80 create mode 160000 src/vendor/vlucas/phpdotenv diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 8626380d..3a9e7525 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -60,6 +60,16 @@ create table workers ( foreign key (role_id) references roles(id) ); + +CREATE TABLE contracts ( + id INT PRIMARY KEY, + contract_type VARCHAR(255), + start_date DATE, + end_date DATE, + salary DECIMAL(10, 2), + worker_id INT, +); + create table work_orders ( id int auto_increment primary key, name varchar(255), diff --git a/src/app/Controllers/ContractController.php b/src/app/Controllers/ContractController.php new file mode 100644 index 00000000..7c732616 --- /dev/null +++ b/src/app/Controllers/ContractController.php @@ -0,0 +1,20 @@ +<?php + +namespace App\Controllers; + +use App\Core\View; +use App\Models\Contract; + +class ContractController +{ + public function index() + { + $contracts = Contract::getAll(); + View::render([ + "view" => "Contracts", + "title" => "Contracts", + "layout" => "MainLayout", + "data" => ["contracts" => $contracts] + ]); + } +} \ No newline at end of file diff --git a/src/app/Layouts/MainLayout.php b/src/app/Layouts/MainLayout.php index 62e27406..2684c325 100755 --- a/src/app/Layouts/MainLayout.php +++ b/src/app/Layouts/MainLayout.php @@ -16,7 +16,7 @@ </div> <nav class="mt-4"> <a href="/" class="block py-2 px-4 text-white hover:bg-gray-700">Home</a> - <a href="#" class="block py-2 px-4 text-white hover:bg-gray-700">Example 1</a> + <a href="/contracts" class="block py-2 px-4 text-white hover:bg-gray-700">contracts</a> <a href="#" class="block py-2 px-4 text-white hover:bg-gray-700">Example 2</a> </nav> </aside> diff --git a/src/app/Models/Contract.php b/src/app/Models/Contract.php new file mode 100644 index 00000000..ca3e72dd --- /dev/null +++ b/src/app/Models/Contract.php @@ -0,0 +1,190 @@ +<?php + +namespace App\Models; + +use App\Core\Database; +use PDO; +use PDOException; + +class Contract +{ + private $id; + private $company; + private $name; + private $dni; + private $password; + private $email; + private $role_id; + private $created_at; + private $deleted_at; + private $updated_at; + + // Constructor to initialize properties (optional) + public function __construct($data = []) + { + foreach ($data as $key => $value) { + $this->$key = $value; + } + } + + // Static method to retrieve all workers + public static function getAll() + { + $query = "SELECT * FROM contracts"; + $results = Database::prepareAndExecute($query); + foreach ($results as $key => $value) { + $results[$key] = new self($value); + } + return $results; + } + + // Static method to find a worker by ID + public static function findById($id) + { + $query = "SELECT * FROM contracts WHERE id = :id AND deleted_at IS NULL"; + $results = Database::prepareAndExecute($query, ['id' => $id]); + + return $results ? new self($results[0]) : null; + } + + // Static method to find a worker by DNI + public static function findByDni($dni) + { + $query = "SELECT * FROM contracts WHERE id = :id AND deleted_at IS NULL"; + $results = Database::prepareAndExecute($query, ['id' => $dni]); + + return $results ? new self($results[0]) : null; + } + + // Method to save a new worker + public function save() + { + $query = "INSERT INTO contracts (company_type, start_date. end_date, salary, worker_id), + VALUES (:company, :name, :dni, :password, :email, :role_id, NOW(), NOW())"; + $params = [ + 'company' => $this->company, + 'name' => $this->name, + 'dni' => $this->dni, + 'password' => password_hash($this->password, PASSWORD_BCRYPT), // Hashing password + 'email' => $this->email, + 'role_id' => $this->role_id + ]; + + return Database::prepareAndExecute($query, $params); + } + + // Method to update an existing worker + public function update() + { + $query = "UPDATE contracts SET contract_type = :company, name = :name, dni = :dni, email = :email, + role_id = :role_id, updated_at = NOW() WHERE id = :id AND deleted_at IS NULL"; + $params = [ + 'id' => $this->id, + 'contract_type' => $this->company, + 'start_date' => $this->name, + 'end_date' => $this->dni, + 'salary' => $this->email, + 'worker_id' => $this->role_id + ]; + + return Database::prepareAndExecute($query, $params); + } + + // Method to delete a worker (soft delete by updating `deleted_at` timestamp) + public function delete() + { + $query = "UPDATE contracts SET deleted_at = NOW() WHERE id = :id"; + return Database::prepareAndExecute($query, ['id' => $this->id]); + } + + // Getters and setters (you can add more as needed) + public function getId() + { + return $this->id; + } + + public function getCompany() + { + return $this->company; + } + + public function getName() + { + return $this->name; + } + + public function getDni() + { + return $this->dni; + } + + public function getPassword() + { + return $this->password; + } + + public function getEmail() + { + return $this->email; + } + + public function getRoleId() + { + return $this->role_id; + } + + public function setId($id) + { + $this->id = $id; + } + + public function setCompany($company) + { + $this->company = $company; + } + + public function setName($name) + { + $this->name = $name; + } + + public function setDni($dni) + { + $this->dni = $dni; + } + + public function setPassword($password) + { + $this->password = $password; + } + + public function setEmail($email) + { + $this->email = $email; + } + + public function setRoleId($role_id) + { + $this->role_id = $role_id; + } + + public function setUpdatedAt($updated_at) + { + $this->updated_at = $updated_at; + } + + public function getCreatedAt() + { + return $this->created_at; + } + + public function getDeletedAt() + { + return $this->deleted_at; + } + + public function getUpdatedAt() + { + return $this->updated_at; + } +} diff --git a/src/app/Views/Contracts.php b/src/app/Views/Contracts.php new file mode 100644 index 00000000..67d4d2ab --- /dev/null +++ b/src/app/Views/Contracts.php @@ -0,0 +1,26 @@ +<div class="overflow-x-auto"> + <table class="min-w-full bg-white border border-gray-300 rounded-lg shadow-md"> + <thead> + <tr class="bg-gray-100 text-left"> + <th class="px-4 py-2 border-b">ID</th> + <th class="px-4 py-2 border-b">Company</th> + <th class="px-4 py-2 border-b">Name</th> + <th class="px-4 py-2 border-b">DNI</th> + <th class="px-4 py-2 border-b">Email</th> + <th class="px-4 py-2 border-b">Role ID</th> + </tr> + </thead> + <tbody> + <?php foreach ($workers as $worker): ?> + <tr class="hover:bg-gray-50"> + <td class="px-4 py-2 border-b"><?php echo $worker->getId(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $worker->getCompany(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $worker->getName(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $worker->getDni(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $worker->getEmail(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $worker->getRoleId(); ?></td> + </tr> + <?php endforeach; ?> + </tbody> + </table> +</div> \ No newline at end of file diff --git a/src/routes/web.php b/src/routes/web.php index 18648278..cd2958d6 100755 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -13,6 +13,7 @@ * **/ +use App\Controllers\ContractController; use App\Controllers\HomeController; use App\Controllers\AuthController; @@ -26,9 +27,9 @@ "controller" => AuthController::class, "method" => "index" ], - "/exemple" => [ - "controller" => HomeController::class, - "method" => "exemple" + "/contracts" => [ + "controller" => ContractController::class, + "method" => "index" ], ], ]; \ No newline at end of file diff --git a/src/vendor/autoload.php b/src/vendor/autoload.php new file mode 100644 index 00000000..4403f11a --- /dev/null +++ b/src/vendor/autoload.php @@ -0,0 +1,25 @@ +<?php + +// autoload.php @generated by Composer + +if (PHP_VERSION_ID < 50600) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + trigger_error( + $err, + E_USER_ERROR + ); +} + +require_once __DIR__ . '/composer/autoload_real.php'; + +return ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194::getLoader(); diff --git a/src/vendor/composer/ClassLoader.php b/src/vendor/composer/ClassLoader.php new file mode 100644 index 00000000..7824d8f7 --- /dev/null +++ b/src/vendor/composer/ClassLoader.php @@ -0,0 +1,579 @@ +<?php + +/* + * This file is part of Composer. + * + * (c) Nils Adermann <naderman@naderman.de> + * Jordi Boggiano <j.boggiano@seld.be> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier <fabien@symfony.com> + * @author Jordi Boggiano <j.boggiano@seld.be> + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array<string, array<string, int>> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array<string, list<string>> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list<string> + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array<string, array<string, list<string>>> + */ + private $prefixesPsr0 = array(); + /** + * @var list<string> + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array<string, string> + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array<string, bool> + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array<string, self> + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array<string, list<string>> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array<string, list<string>> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list<string> + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list<string> + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array<string, string> Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array<string, string> $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list<string>|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list<string>|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list<string>|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list<string>|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array<string, self> + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/src/vendor/composer/InstalledVersions.php b/src/vendor/composer/InstalledVersions.php new file mode 100644 index 00000000..51e734a7 --- /dev/null +++ b/src/vendor/composer/InstalledVersions.php @@ -0,0 +1,359 @@ +<?php + +/* + * This file is part of Composer. + * + * (c) Nils Adermann <naderman@naderman.de> + * Jordi Boggiano <j.boggiano@seld.be> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list<string> + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list<string> + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/src/vendor/composer/LICENSE b/src/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/src/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/src/vendor/composer/autoload_classmap.php b/src/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..f6834955 --- /dev/null +++ b/src/vendor/composer/autoload_classmap.php @@ -0,0 +1,15 @@ +<?php + +// autoload_classmap.php @generated by Composer + +$vendorDir = dirname(__DIR__); +$baseDir = dirname(dirname($vendorDir)); + +return array( + 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', + 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', +); diff --git a/src/vendor/composer/autoload_files.php b/src/vendor/composer/autoload_files.php new file mode 100644 index 00000000..cd554148 --- /dev/null +++ b/src/vendor/composer/autoload_files.php @@ -0,0 +1,12 @@ +<?php + +// autoload_files.php @generated by Composer + +$vendorDir = dirname(__DIR__); +$baseDir = dirname(dirname($vendorDir)); + +return array( + '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', + 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', +); diff --git a/src/vendor/composer/autoload_namespaces.php b/src/vendor/composer/autoload_namespaces.php new file mode 100644 index 00000000..f1ae7a0f --- /dev/null +++ b/src/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ +<?php + +// autoload_namespaces.php @generated by Composer + +$vendorDir = dirname(__DIR__); +$baseDir = dirname(dirname($vendorDir)); + +return array( +); diff --git a/src/vendor/composer/autoload_psr4.php b/src/vendor/composer/autoload_psr4.php new file mode 100644 index 00000000..7c937f26 --- /dev/null +++ b/src/vendor/composer/autoload_psr4.php @@ -0,0 +1,16 @@ +<?php + +// autoload_psr4.php @generated by Composer + +$vendorDir = dirname(__DIR__); +$baseDir = dirname(dirname($vendorDir)); + +return array( + 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), + 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), + 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), + 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'), + 'GrahamCampbell\\ResultType\\' => array($vendorDir . '/graham-campbell/result-type/src'), + 'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), + 'App\\' => array($baseDir . '/src/app'), +); diff --git a/src/vendor/composer/autoload_real.php b/src/vendor/composer/autoload_real.php new file mode 100644 index 00000000..a686a7e4 --- /dev/null +++ b/src/vendor/composer/autoload_real.php @@ -0,0 +1,50 @@ +<?php + +// autoload_real.php @generated by Composer + +class ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194 +{ + private static $loader; + + public static function loadClassLoader($class) + { + if ('Composer\Autoload\ClassLoader' === $class) { + require __DIR__ . '/ClassLoader.php'; + } + } + + /** + * @return \Composer\Autoload\ClassLoader + */ + public static function getLoader() + { + if (null !== self::$loader) { + return self::$loader; + } + + require __DIR__ . '/platform_check.php'; + + spl_autoload_register(array('ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194', 'loadClassLoader'), true, true); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); + spl_autoload_unregister(array('ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194', 'loadClassLoader')); + + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticIniteb55ab41b565401c02d945b712f3b194::getInitializer($loader)); + + $loader->register(true); + + $filesToLoad = \Composer\Autoload\ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); + } + + return $loader; + } +} diff --git a/src/vendor/composer/autoload_static.php b/src/vendor/composer/autoload_static.php new file mode 100644 index 00000000..5bbd9ff1 --- /dev/null +++ b/src/vendor/composer/autoload_static.php @@ -0,0 +1,89 @@ +<?php + +// autoload_static.php @generated by Composer + +namespace Composer\Autoload; + +class ComposerStaticIniteb55ab41b565401c02d945b712f3b194 +{ + public static $files = array ( + '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', + 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'S' => + array ( + 'Symfony\\Polyfill\\Php80\\' => 23, + 'Symfony\\Polyfill\\Mbstring\\' => 26, + 'Symfony\\Polyfill\\Ctype\\' => 23, + ), + 'P' => + array ( + 'PhpOption\\' => 10, + ), + 'G' => + array ( + 'GrahamCampbell\\ResultType\\' => 26, + ), + 'D' => + array ( + 'Dotenv\\' => 7, + ), + 'A' => + array ( + 'App\\' => 4, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Symfony\\Polyfill\\Php80\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', + ), + 'Symfony\\Polyfill\\Mbstring\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', + ), + 'Symfony\\Polyfill\\Ctype\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', + ), + 'PhpOption\\' => + array ( + 0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption', + ), + 'GrahamCampbell\\ResultType\\' => + array ( + 0 => __DIR__ . '/..' . '/graham-campbell/result-type/src', + ), + 'Dotenv\\' => + array ( + 0 => __DIR__ . '/..' . '/vlucas/phpdotenv/src', + ), + 'App\\' => + array ( + 0 => __DIR__ . '/../../..' . '/src/app', + ), + ); + + public static $classMap = array ( + 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', + 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixDirsPsr4; + $loader->classMap = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/src/vendor/composer/installed.json b/src/vendor/composer/installed.json new file mode 100644 index 00000000..82aca11a --- /dev/null +++ b/src/vendor/composer/installed.json @@ -0,0 +1,484 @@ +{ + "packages": [ + { + "name": "graham-campbell/result-type", + "version": "v1.1.3", + "version_normalized": "1.1.3.0", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "3ba905c11371512af9d9bdd27d99b782216b6945" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945", + "reference": "3ba905c11371512af9d9bdd27d99b782216b6945", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9.3" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + }, + "time": "2024-07-20T21:45:45+00:00", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "install-path": "../graham-campbell/result-type" + }, + { + "name": "phpoption/phpoption", + "version": "1.9.3", + "version_normalized": "1.9.3.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54", + "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + }, + "time": "2024-07-20T21:41:07+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.9.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "install-path": "../phpoption/phpoption" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "source", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-ctype" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "source", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-mbstring" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "source", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php80" + }, + { + "name": "vlucas/phpdotenv", + "version": "v5.6.1", + "version_normalized": "5.6.1.0", + "source": { + "type": "git", + "url": "https://github.com/vlucas/phpdotenv.git", + "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2", + "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "graham-campbell/result-type": "^1.1.3", + "php": "^7.2.5 || ^8.0", + "phpoption/phpoption": "^1.9.3", + "symfony/polyfill-ctype": "^1.24", + "symfony/polyfill-mbstring": "^1.24", + "symfony/polyfill-php80": "^1.24" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-filter": "*", + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" + }, + "suggest": { + "ext-filter": "Required to use the boolean validator." + }, + "time": "2024-07-20T21:52:34+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, + "branch-alias": { + "dev-master": "5.6-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-4": { + "Dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Vance Lucas", + "email": "vance@vancelucas.com", + "homepage": "https://github.com/vlucas" + } + ], + "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", + "keywords": [ + "dotenv", + "env", + "environment" + ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "install-path": "../vlucas/phpdotenv" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/src/vendor/composer/installed.php b/src/vendor/composer/installed.php new file mode 100644 index 00000000..3d3f105c --- /dev/null +++ b/src/vendor/composer/installed.php @@ -0,0 +1,77 @@ +<?php return array( + 'root' => array( + 'name' => 'daw-iesmontsia/urban-tree', + 'pretty_version' => 'dev-main', + 'version' => 'dev-main', + 'reference' => 'dda517b3a94edde383dd54b01a57135aea08ebc4', + 'type' => 'project', + 'install_path' => __DIR__ . '/../../../', + 'aliases' => array(), + 'dev' => true, + ), + 'versions' => array( + 'daw-iesmontsia/urban-tree' => array( + 'pretty_version' => 'dev-main', + 'version' => 'dev-main', + 'reference' => 'dda517b3a94edde383dd54b01a57135aea08ebc4', + 'type' => 'project', + 'install_path' => __DIR__ . '/../../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'graham-campbell/result-type' => array( + 'pretty_version' => 'v1.1.3', + 'version' => '1.1.3.0', + 'reference' => '3ba905c11371512af9d9bdd27d99b782216b6945', + 'type' => 'library', + 'install_path' => __DIR__ . '/../graham-campbell/result-type', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'phpoption/phpoption' => array( + 'pretty_version' => '1.9.3', + 'version' => '1.9.3.0', + 'reference' => 'e3fac8b24f56113f7cb96af14958c0dd16330f54', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpoption/phpoption', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-ctype' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-mbstring' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'vlucas/phpdotenv' => array( + 'pretty_version' => 'v5.6.1', + 'version' => '5.6.1.0', + 'reference' => 'a59a13791077fe3d44f90e7133eb68e7d22eaff2', + 'type' => 'library', + 'install_path' => __DIR__ . '/../vlucas/phpdotenv', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +); diff --git a/src/vendor/composer/platform_check.php b/src/vendor/composer/platform_check.php new file mode 100644 index 00000000..a8b98d5c --- /dev/null +++ b/src/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ +<?php + +// platform_check.php @generated by Composer + +$issues = array(); + +if (!(PHP_VERSION_ID >= 70205)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/src/vendor/graham-campbell/result-type b/src/vendor/graham-campbell/result-type new file mode 160000 index 00000000..3ba905c1 --- /dev/null +++ b/src/vendor/graham-campbell/result-type @@ -0,0 +1 @@ +Subproject commit 3ba905c11371512af9d9bdd27d99b782216b6945 diff --git a/src/vendor/phpoption/phpoption b/src/vendor/phpoption/phpoption new file mode 160000 index 00000000..e3fac8b2 --- /dev/null +++ b/src/vendor/phpoption/phpoption @@ -0,0 +1 @@ +Subproject commit e3fac8b24f56113f7cb96af14958c0dd16330f54 diff --git a/src/vendor/symfony/polyfill-ctype b/src/vendor/symfony/polyfill-ctype new file mode 160000 index 00000000..a3cc8b04 --- /dev/null +++ b/src/vendor/symfony/polyfill-ctype @@ -0,0 +1 @@ +Subproject commit a3cc8b044a6ea513310cbd48ef7333b384945638 diff --git a/src/vendor/symfony/polyfill-mbstring b/src/vendor/symfony/polyfill-mbstring new file mode 160000 index 00000000..85181ba9 --- /dev/null +++ b/src/vendor/symfony/polyfill-mbstring @@ -0,0 +1 @@ +Subproject commit 85181ba99b2345b0ef10ce42ecac37612d9fd341 diff --git a/src/vendor/symfony/polyfill-php80 b/src/vendor/symfony/polyfill-php80 new file mode 160000 index 00000000..60328e36 --- /dev/null +++ b/src/vendor/symfony/polyfill-php80 @@ -0,0 +1 @@ +Subproject commit 60328e362d4c2c802a54fcbf04f9d3fb892b4cf8 diff --git a/src/vendor/vlucas/phpdotenv b/src/vendor/vlucas/phpdotenv new file mode 160000 index 00000000..a59a1379 --- /dev/null +++ b/src/vendor/vlucas/phpdotenv @@ -0,0 +1 @@ +Subproject commit a59a13791077fe3d44f90e7133eb68e7d22eaff2 From 9e30a69819bd65010c61dea714f385c04859de3f Mon Sep 17 00:00:00 2001 From: "Chuck.D.Norris" <boveoriol@gmail.com> Date: Thu, 14 Nov 2024 16:27:30 +0100 Subject: [PATCH 2/9] feat(contract): add contract MVC --- src/app/Core/Logger.php | 12 +-- src/app/Models/Contract.php | 142 +++++++++++++----------------------- src/app/Views/Contracts.php | 26 +++---- 3 files changed, 68 insertions(+), 112 deletions(-) diff --git a/src/app/Core/Logger.php b/src/app/Core/Logger.php index 625509ba..fc489451 100755 --- a/src/app/Core/Logger.php +++ b/src/app/Core/Logger.php @@ -6,12 +6,12 @@ class Logger { public static function log($message, $level = 'info') { - $logFile = getenv("LOG_FILE_PATH"); - $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; - if (!file_exists($logFile)) { - touch($logFile); - } - file_put_contents($logFile, $logMessage, FILE_APPEND); + // $logFile = getenv("LOG_FILE_PATH"); + // $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; + // if (!file_exists($logFile)) { + // touch($logFile); + // } + // file_put_contents($logFile, $logMessage, FILE_APPEND); } } diff --git a/src/app/Models/Contract.php b/src/app/Models/Contract.php index ca3e72dd..f6b50211 100644 --- a/src/app/Models/Contract.php +++ b/src/app/Models/Contract.php @@ -9,17 +9,13 @@ class Contract { private $id; - private $company; - private $name; - private $dni; - private $password; - private $email; - private $role_id; - private $created_at; - private $deleted_at; - private $updated_at; - - // Constructor to initialize properties (optional) + private $contract_type; + private $start_date; + private $end_date; + private $salary; + private $worker_id; + + // Constructor per inicialitzar les propietats public function __construct($data = []) { foreach ($data as $key => $value) { @@ -27,7 +23,7 @@ public function __construct($data = []) } } - // Static method to retrieve all workers + // Mètode per obtenir tots els contractes public static function getAll() { $query = "SELECT * FROM contracts"; @@ -38,99 +34,84 @@ public static function getAll() return $results; } - // Static method to find a worker by ID + // Mètode per obtenir un contracte per ID public static function findById($id) { - $query = "SELECT * FROM contracts WHERE id = :id AND deleted_at IS NULL"; + $query = "SELECT * FROM contracts WHERE id = :id"; $results = Database::prepareAndExecute($query, ['id' => $id]); return $results ? new self($results[0]) : null; } - // Static method to find a worker by DNI - public static function findByDni($dni) - { - $query = "SELECT * FROM contracts WHERE id = :id AND deleted_at IS NULL"; - $results = Database::prepareAndExecute($query, ['id' => $dni]); - - return $results ? new self($results[0]) : null; - } - - // Method to save a new worker + // Mètode per guardar un nou contracte public function save() { - $query = "INSERT INTO contracts (company_type, start_date. end_date, salary, worker_id), - VALUES (:company, :name, :dni, :password, :email, :role_id, NOW(), NOW())"; + $query = "INSERT INTO contracts (contract_type, start_date, end_date, salary, worker_id) + VALUES (:contract_type, :start_date, :end_date, :salary, :worker_id)"; $params = [ - 'company' => $this->company, - 'name' => $this->name, - 'dni' => $this->dni, - 'password' => password_hash($this->password, PASSWORD_BCRYPT), // Hashing password - 'email' => $this->email, - 'role_id' => $this->role_id + 'contract_type' => $this->contract_type, + 'start_date' => $this->start_date, + 'end_date' => $this->end_date, + 'salary' => $this->salary, + 'worker_id' => $this->worker_id, ]; return Database::prepareAndExecute($query, $params); } - // Method to update an existing worker + // Mètode per actualitzar un contracte existent public function update() { - $query = "UPDATE contracts SET contract_type = :company, name = :name, dni = :dni, email = :email, - role_id = :role_id, updated_at = NOW() WHERE id = :id AND deleted_at IS NULL"; + $query = "UPDATE contracts SET contract_type = :contract_type, start_date = :start_date, + end_date = :end_date, salary = :salary, worker_id = :worker_id WHERE id = :id"; $params = [ + 'contract_type' => $this->contract_type, + 'start_date' => $this->start_date, + 'end_date' => $this->end_date, + 'salary' => $this->salary, + 'worker_id' => $this->worker_id, 'id' => $this->id, - 'contract_type' => $this->company, - 'start_date' => $this->name, - 'end_date' => $this->dni, - 'salary' => $this->email, - 'worker_id' => $this->role_id ]; return Database::prepareAndExecute($query, $params); } - // Method to delete a worker (soft delete by updating `deleted_at` timestamp) + // Mètode per esborrar un contracte public function delete() { - $query = "UPDATE contracts SET deleted_at = NOW() WHERE id = :id"; + $query = "DELETE FROM contracts WHERE id = :id"; return Database::prepareAndExecute($query, ['id' => $this->id]); } - // Getters and setters (you can add more as needed) + // Getters i setters public function getId() { return $this->id; } - public function getCompany() + public function getContractType() { - return $this->company; + return $this->contract_type; } - public function getName() + public function getStartDate() { - return $this->name; + return $this->start_date; } - public function getDni() + public function getEndDate() { - return $this->dni; + return $this->end_date; } - public function getPassword() + public function getSalary() { - return $this->password; + return $this->salary; } - public function getEmail() + public function getWorkerId() { - return $this->email; - } - - public function getRoleId() - { - return $this->role_id; + return $this->worker_id; } public function setId($id) @@ -138,53 +119,28 @@ public function setId($id) $this->id = $id; } - public function setCompany($company) - { - $this->company = $company; - } - - public function setName($name) - { - $this->name = $name; - } - - public function setDni($dni) - { - $this->dni = $dni; - } - - public function setPassword($password) - { - $this->password = $password; - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function setRoleId($role_id) + public function setContractType($contract_type) { - $this->role_id = $role_id; + $this->contract_type = $contract_type; } - public function setUpdatedAt($updated_at) + public function setStartDate($start_date) { - $this->updated_at = $updated_at; + $this->start_date = $start_date; } - public function getCreatedAt() + public function setEndDate($end_date) { - return $this->created_at; + $this->end_date = $end_date; } - public function getDeletedAt() + public function setSalary($salary) { - return $this->deleted_at; + $this->salary = $salary; } - public function getUpdatedAt() + public function setWorkerId($worker_id) { - return $this->updated_at; + $this->worker_id = $worker_id; } } diff --git a/src/app/Views/Contracts.php b/src/app/Views/Contracts.php index 67d4d2ab..11ad5eec 100644 --- a/src/app/Views/Contracts.php +++ b/src/app/Views/Contracts.php @@ -3,24 +3,24 @@ <thead> <tr class="bg-gray-100 text-left"> <th class="px-4 py-2 border-b">ID</th> - <th class="px-4 py-2 border-b">Company</th> - <th class="px-4 py-2 border-b">Name</th> - <th class="px-4 py-2 border-b">DNI</th> - <th class="px-4 py-2 border-b">Email</th> - <th class="px-4 py-2 border-b">Role ID</th> + <th class="px-4 py-2 border-b">Contract Type</th> + <th class="px-4 py-2 border-b">Start Date</th> + <th class="px-4 py-2 border-b">End Date</th> + <th class="px-4 py-2 border-b">Salary</th> + <th class="px-4 py-2 border-b">Worker ID</th> </tr> </thead> <tbody> - <?php foreach ($workers as $worker): ?> + <?php foreach ($contracts as $contract): ?> <tr class="hover:bg-gray-50"> - <td class="px-4 py-2 border-b"><?php echo $worker->getId(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $worker->getCompany(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $worker->getName(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $worker->getDni(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $worker->getEmail(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $worker->getRoleId(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->getId(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->getContractType(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->getStartDate(); ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->getEndDate(); ?></td> + <td class="px-4 py-2 border-b"><?php echo number_format($contract->getSalary(), 2); ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->getWorkerId(); ?></td> </tr> <?php endforeach; ?> </tbody> </table> -</div> \ No newline at end of file +</div> From 4894fe5cd378809fcd3997a718d1888570b71f9f Mon Sep 17 00:00:00 2001 From: "Chuck.D.Norris" <boveoriol@gmail.com> Date: Thu, 14 Nov 2024 16:28:26 +0100 Subject: [PATCH 3/9] fix(database): modify contract to fix errors --- docker/database/start-scripts/0-init.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 3a9e7525..672c33a3 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -62,12 +62,12 @@ create table workers ( CREATE TABLE contracts ( - id INT PRIMARY KEY, + id int auto_increment primary key, contract_type VARCHAR(255), start_date DATE, end_date DATE, salary DECIMAL(10, 2), - worker_id INT, + worker_id INT ); create table work_orders ( From a9ba0ee65f9217d1ff460921ce5b47c9bce25de5 Mon Sep 17 00:00:00 2001 From: "Chuck.D.Norris" <boveoriol@gmail.com> Date: Thu, 14 Nov 2024 16:43:09 +0100 Subject: [PATCH 4/9] Revert "feat(contract): add Contract" This reverts commit 924d495141062f7d734b542827976433c3729334. --- src/app/Layouts/MainLayout.php | 2 +- src/app/routes.php | 7 +- src/vendor/autoload.php | 25 - src/vendor/composer/ClassLoader.php | 579 -------------------- src/vendor/composer/InstalledVersions.php | 359 ------------ src/vendor/composer/LICENSE | 21 - src/vendor/composer/autoload_classmap.php | 15 - src/vendor/composer/autoload_files.php | 12 - src/vendor/composer/autoload_namespaces.php | 9 - src/vendor/composer/autoload_psr4.php | 16 - src/vendor/composer/autoload_real.php | 50 -- src/vendor/composer/autoload_static.php | 89 --- src/vendor/composer/installed.json | 484 ---------------- src/vendor/composer/installed.php | 77 --- src/vendor/composer/platform_check.php | 26 - 15 files changed, 4 insertions(+), 1767 deletions(-) delete mode 100644 src/vendor/autoload.php delete mode 100644 src/vendor/composer/ClassLoader.php delete mode 100644 src/vendor/composer/InstalledVersions.php delete mode 100644 src/vendor/composer/LICENSE delete mode 100644 src/vendor/composer/autoload_classmap.php delete mode 100644 src/vendor/composer/autoload_files.php delete mode 100644 src/vendor/composer/autoload_namespaces.php delete mode 100644 src/vendor/composer/autoload_psr4.php delete mode 100644 src/vendor/composer/autoload_real.php delete mode 100644 src/vendor/composer/autoload_static.php delete mode 100644 src/vendor/composer/installed.json delete mode 100644 src/vendor/composer/installed.php delete mode 100644 src/vendor/composer/platform_check.php diff --git a/src/app/Layouts/MainLayout.php b/src/app/Layouts/MainLayout.php index 2684c325..62e27406 100755 --- a/src/app/Layouts/MainLayout.php +++ b/src/app/Layouts/MainLayout.php @@ -16,7 +16,7 @@ </div> <nav class="mt-4"> <a href="/" class="block py-2 px-4 text-white hover:bg-gray-700">Home</a> - <a href="/contracts" class="block py-2 px-4 text-white hover:bg-gray-700">contracts</a> + <a href="#" class="block py-2 px-4 text-white hover:bg-gray-700">Example 1</a> <a href="#" class="block py-2 px-4 text-white hover:bg-gray-700">Example 2</a> </nav> </aside> diff --git a/src/app/routes.php b/src/app/routes.php index cd2958d6..18648278 100644 --- a/src/app/routes.php +++ b/src/app/routes.php @@ -13,7 +13,6 @@ * **/ -use App\Controllers\ContractController; use App\Controllers\HomeController; use App\Controllers\AuthController; @@ -27,9 +26,9 @@ "controller" => AuthController::class, "method" => "index" ], - "/contracts" => [ - "controller" => ContractController::class, - "method" => "index" + "/exemple" => [ + "controller" => HomeController::class, + "method" => "exemple" ], ], ]; \ No newline at end of file diff --git a/src/vendor/autoload.php b/src/vendor/autoload.php deleted file mode 100644 index 4403f11a..00000000 --- a/src/vendor/autoload.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -// autoload.php @generated by Composer - -if (PHP_VERSION_ID < 50600) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, $err); - } elseif (!headers_sent()) { - echo $err; - } - } - trigger_error( - $err, - E_USER_ERROR - ); -} - -require_once __DIR__ . '/composer/autoload_real.php'; - -return ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194::getLoader(); diff --git a/src/vendor/composer/ClassLoader.php b/src/vendor/composer/ClassLoader.php deleted file mode 100644 index 7824d8f7..00000000 --- a/src/vendor/composer/ClassLoader.php +++ /dev/null @@ -1,579 +0,0 @@ -<?php - -/* - * This file is part of Composer. - * - * (c) Nils Adermann <naderman@naderman.de> - * Jordi Boggiano <j.boggiano@seld.be> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier <fabien@symfony.com> - * @author Jordi Boggiano <j.boggiano@seld.be> - * @see https://www.php-fig.org/psr/psr-0/ - * @see https://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - /** @var \Closure(string):void */ - private static $includeFile; - - /** @var string|null */ - private $vendorDir; - - // PSR-4 - /** - * @var array<string, array<string, int>> - */ - private $prefixLengthsPsr4 = array(); - /** - * @var array<string, list<string>> - */ - private $prefixDirsPsr4 = array(); - /** - * @var list<string> - */ - private $fallbackDirsPsr4 = array(); - - // PSR-0 - /** - * List of PSR-0 prefixes - * - * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) - * - * @var array<string, array<string, list<string>>> - */ - private $prefixesPsr0 = array(); - /** - * @var list<string> - */ - private $fallbackDirsPsr0 = array(); - - /** @var bool */ - private $useIncludePath = false; - - /** - * @var array<string, string> - */ - private $classMap = array(); - - /** @var bool */ - private $classMapAuthoritative = false; - - /** - * @var array<string, bool> - */ - private $missingClasses = array(); - - /** @var string|null */ - private $apcuPrefix; - - /** - * @var array<string, self> - */ - private static $registeredLoaders = array(); - - /** - * @param string|null $vendorDir - */ - public function __construct($vendorDir = null) - { - $this->vendorDir = $vendorDir; - self::initializeIncludeClosure(); - } - - /** - * @return array<string, list<string>> - */ - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); - } - - return array(); - } - - /** - * @return array<string, list<string>> - */ - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - /** - * @return list<string> - */ - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - /** - * @return list<string> - */ - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - /** - * @return array<string, string> Array of classname => path - */ - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array<string, string> $classMap Class to filename map - * - * @return void - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param list<string>|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - * - * @return void - */ - public function add($prefix, $paths, $prepend = false) - { - $paths = (array) $paths; - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list<string>|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - $paths = (array) $paths; - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param list<string>|string $paths The PSR-0 base directories - * - * @return void - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list<string>|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - * - * @return void - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - * - * @return void - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - * - * @return void - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - * - * @return void - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - * - * @return void - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - - if (null === $this->vendorDir) { - return; - } - - if ($prepend) { - self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; - } else { - unset(self::$registeredLoaders[$this->vendorDir]); - self::$registeredLoaders[$this->vendorDir] = $this; - } - } - - /** - * Unregisters this instance as an autoloader. - * - * @return void - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - - if (null !== $this->vendorDir) { - unset(self::$registeredLoaders[$this->vendorDir]); - } - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return true|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - $includeFile = self::$includeFile; - $includeFile($file); - - return true; - } - - return null; - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - /** - * Returns the currently registered loaders keyed by their corresponding vendor directories. - * - * @return array<string, self> - */ - public static function getRegisteredLoaders() - { - return self::$registeredLoaders; - } - - /** - * @param string $class - * @param string $ext - * @return string|false - */ - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath . '\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } - - /** - * @return void - */ - private static function initializeIncludeClosure() - { - if (self::$includeFile !== null) { - return; - } - - /** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - */ - self::$includeFile = \Closure::bind(static function($file) { - include $file; - }, null, null); - } -} diff --git a/src/vendor/composer/InstalledVersions.php b/src/vendor/composer/InstalledVersions.php deleted file mode 100644 index 51e734a7..00000000 --- a/src/vendor/composer/InstalledVersions.php +++ /dev/null @@ -1,359 +0,0 @@ -<?php - -/* - * This file is part of Composer. - * - * (c) Nils Adermann <naderman@naderman.de> - * Jordi Boggiano <j.boggiano@seld.be> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer; - -use Composer\Autoload\ClassLoader; -use Composer\Semver\VersionParser; - -/** - * This class is copied in every Composer installed project and available to all - * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` - * - * @final - */ -class InstalledVersions -{ - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ - private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> - */ - private static $installedByVendor = array(); - - /** - * Returns a list of all package names which are present, either by being installed, replaced or provided - * - * @return string[] - * @psalm-return list<string> - */ - public static function getInstalledPackages() - { - $packages = array(); - foreach (self::getInstalled() as $installed) { - $packages[] = array_keys($installed['versions']); - } - - if (1 === \count($packages)) { - return $packages[0]; - } - - return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); - } - - /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list<string> - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - - /** - * Checks whether the given package is installed - * - * This also returns true if the package name is provided or replaced by another package - * - * @param string $packageName - * @param bool $includeDevRequirements - * @return bool - */ - public static function isInstalled($packageName, $includeDevRequirements = true) - { - foreach (self::getInstalled() as $installed) { - if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; - } - } - - return false; - } - - /** - * Checks whether the given package satisfies a version constraint - * - * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: - * - * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') - * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package - * @return bool - */ - public static function satisfies(VersionParser $parser, $packageName, $constraint) - { - $constraint = $parser->parseConstraints((string) $constraint); - $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - - return $provided->matches($constraint); - } - - /** - * Returns a version constraint representing all the range(s) which are installed for a given package - * - * It is easier to use this via isInstalled() with the $constraint argument if you need to check - * whether a given version of a package is installed, and not just whether it exists - * - * @param string $packageName - * @return string Version constraint usable with composer/semver - */ - public static function getVersionRanges($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - $ranges = array(); - if (isset($installed['versions'][$packageName]['pretty_version'])) { - $ranges[] = $installed['versions'][$packageName]['pretty_version']; - } - if (array_key_exists('aliases', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); - } - if (array_key_exists('replaced', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); - } - if (array_key_exists('provided', $installed['versions'][$packageName])) { - $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); - } - - return implode(' || ', $ranges); - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['version'])) { - return null; - } - - return $installed['versions'][$packageName]['version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present - */ - public static function getPrettyVersion($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['pretty_version'])) { - return null; - } - - return $installed['versions'][$packageName]['pretty_version']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference - */ - public static function getReference($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - if (!isset($installed['versions'][$packageName]['reference'])) { - return null; - } - - return $installed['versions'][$packageName]['reference']; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - - /** - * @return array - * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} - */ - public static function getRootPackage() - { - $installed = self::getInstalled(); - - return $installed[0]['root']; - } - - /** - * Returns the raw installed.php data for custom implementations - * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. - * @return array[] - * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} - */ - public static function getRawData() - { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - - return self::$installed; - } - - /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - - /** - * Lets you reload the static array from another file - * - * This is only useful for complex integrations in which a project needs to use - * this class but then also needs to execute another project's autoloader in process, - * and wants to ensure both projects have access to their version of installed.php. - * - * A typical case would be PHPUnit, where it would need to make sure it reads all - * the data it needs from this class, then call reload() with - * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure - * the project in which it runs can then also use this class safely, without - * interference between PHPUnit's dependencies and the project's dependencies. - * - * @param array[] $data A vendor/composer/installed.php data set - * @return void - * - * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data - */ - public static function reload($data) - { - self::$installed = $data; - self::$installedByVendor = array(); - } - - /** - * @return array[] - * @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}> - */ - private static function getInstalled() - { - if (null === self::$canGetVendors) { - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); - } - - $installed = array(); - - if (self::$canGetVendors) { - foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { - if (isset(self::$installedByVendor[$vendorDir])) { - $installed[] = self::$installedByVendor[$vendorDir]; - } elseif (is_file($vendorDir.'/composer/installed.php')) { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ - $required = require $vendorDir.'/composer/installed.php'; - $installed[] = self::$installedByVendor[$vendorDir] = $required; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } - } - } - } - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ - $required = require __DIR__ . '/installed.php'; - self::$installed = $required; - } else { - self::$installed = array(); - } - } - - if (self::$installed !== array()) { - $installed[] = self::$installed; - } - - return $installed; - } -} diff --git a/src/vendor/composer/LICENSE b/src/vendor/composer/LICENSE deleted file mode 100644 index f27399a0..00000000 --- a/src/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/src/vendor/composer/autoload_classmap.php b/src/vendor/composer/autoload_classmap.php deleted file mode 100644 index f6834955..00000000 --- a/src/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -// autoload_classmap.php @generated by Composer - -$vendorDir = dirname(__DIR__); -$baseDir = dirname(dirname($vendorDir)); - -return array( - 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', - 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', - 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', - 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', -); diff --git a/src/vendor/composer/autoload_files.php b/src/vendor/composer/autoload_files.php deleted file mode 100644 index cd554148..00000000 --- a/src/vendor/composer/autoload_files.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -// autoload_files.php @generated by Composer - -$vendorDir = dirname(__DIR__); -$baseDir = dirname(dirname($vendorDir)); - -return array( - '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', - 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', -); diff --git a/src/vendor/composer/autoload_namespaces.php b/src/vendor/composer/autoload_namespaces.php deleted file mode 100644 index f1ae7a0f..00000000 --- a/src/vendor/composer/autoload_namespaces.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -// autoload_namespaces.php @generated by Composer - -$vendorDir = dirname(__DIR__); -$baseDir = dirname(dirname($vendorDir)); - -return array( -); diff --git a/src/vendor/composer/autoload_psr4.php b/src/vendor/composer/autoload_psr4.php deleted file mode 100644 index 7c937f26..00000000 --- a/src/vendor/composer/autoload_psr4.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -// autoload_psr4.php @generated by Composer - -$vendorDir = dirname(__DIR__); -$baseDir = dirname(dirname($vendorDir)); - -return array( - 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), - 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), - 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), - 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'), - 'GrahamCampbell\\ResultType\\' => array($vendorDir . '/graham-campbell/result-type/src'), - 'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), - 'App\\' => array($baseDir . '/src/app'), -); diff --git a/src/vendor/composer/autoload_real.php b/src/vendor/composer/autoload_real.php deleted file mode 100644 index a686a7e4..00000000 --- a/src/vendor/composer/autoload_real.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -// autoload_real.php @generated by Composer - -class ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194 -{ - private static $loader; - - public static function loadClassLoader($class) - { - if ('Composer\Autoload\ClassLoader' === $class) { - require __DIR__ . '/ClassLoader.php'; - } - } - - /** - * @return \Composer\Autoload\ClassLoader - */ - public static function getLoader() - { - if (null !== self::$loader) { - return self::$loader; - } - - require __DIR__ . '/platform_check.php'; - - spl_autoload_register(array('ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderIniteb55ab41b565401c02d945b712f3b194', 'loadClassLoader')); - - require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticIniteb55ab41b565401c02d945b712f3b194::getInitializer($loader)); - - $loader->register(true); - - $filesToLoad = \Composer\Autoload\ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$files; - $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - - require $file; - } - }, null, null); - foreach ($filesToLoad as $fileIdentifier => $file) { - $requireFile($fileIdentifier, $file); - } - - return $loader; - } -} diff --git a/src/vendor/composer/autoload_static.php b/src/vendor/composer/autoload_static.php deleted file mode 100644 index 5bbd9ff1..00000000 --- a/src/vendor/composer/autoload_static.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -// autoload_static.php @generated by Composer - -namespace Composer\Autoload; - -class ComposerStaticIniteb55ab41b565401c02d945b712f3b194 -{ - public static $files = array ( - '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', - 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', - ); - - public static $prefixLengthsPsr4 = array ( - 'S' => - array ( - 'Symfony\\Polyfill\\Php80\\' => 23, - 'Symfony\\Polyfill\\Mbstring\\' => 26, - 'Symfony\\Polyfill\\Ctype\\' => 23, - ), - 'P' => - array ( - 'PhpOption\\' => 10, - ), - 'G' => - array ( - 'GrahamCampbell\\ResultType\\' => 26, - ), - 'D' => - array ( - 'Dotenv\\' => 7, - ), - 'A' => - array ( - 'App\\' => 4, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'Symfony\\Polyfill\\Php80\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', - ), - 'Symfony\\Polyfill\\Mbstring\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', - ), - 'Symfony\\Polyfill\\Ctype\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', - ), - 'PhpOption\\' => - array ( - 0 => __DIR__ . '/..' . '/phpoption/phpoption/src/PhpOption', - ), - 'GrahamCampbell\\ResultType\\' => - array ( - 0 => __DIR__ . '/..' . '/graham-campbell/result-type/src', - ), - 'Dotenv\\' => - array ( - 0 => __DIR__ . '/..' . '/vlucas/phpdotenv/src', - ), - 'App\\' => - array ( - 0 => __DIR__ . '/../../..' . '/src/app', - ), - ); - - public static $classMap = array ( - 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', - 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', - 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', - 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$prefixDirsPsr4; - $loader->classMap = ComposerStaticIniteb55ab41b565401c02d945b712f3b194::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/src/vendor/composer/installed.json b/src/vendor/composer/installed.json deleted file mode 100644 index 82aca11a..00000000 --- a/src/vendor/composer/installed.json +++ /dev/null @@ -1,484 +0,0 @@ -{ - "packages": [ - { - "name": "graham-campbell/result-type", - "version": "v1.1.3", - "version_normalized": "1.1.3.0", - "source": { - "type": "git", - "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" - }, - "time": "2024-07-20T21:45:45+00:00", - "type": "library", - "installation-source": "source", - "autoload": { - "psr-4": { - "GrahamCampbell\\ResultType\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "An Implementation Of The Result Type", - "keywords": [ - "Graham Campbell", - "GrahamCampbell", - "Result Type", - "Result-Type", - "result" - ], - "support": { - "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", - "type": "tidelift" - } - ], - "install-path": "../graham-campbell/result-type" - }, - { - "name": "phpoption/phpoption", - "version": "1.9.3", - "version_normalized": "1.9.3.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" - }, - "time": "2024-07-20T21:41:07+00:00", - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - }, - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "installation-source": "source", - "autoload": { - "psr-4": { - "PhpOption\\": "src/PhpOption/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh" - }, - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "support": { - "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.3" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], - "install-path": "../phpoption/phpoption" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "time": "2024-09-09T11:45:10+00:00", - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "source", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "install-path": "../symfony/polyfill-ctype" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "time": "2024-09-09T11:45:10+00:00", - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "source", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "install-path": "../symfony/polyfill-mbstring" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.31.0", - "version_normalized": "1.31.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "time": "2024-09-09T11:45:10+00:00", - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "source", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "install-path": "../symfony/polyfill-php80" - }, - { - "name": "vlucas/phpdotenv", - "version": "v5.6.1", - "version_normalized": "5.6.1.0", - "source": { - "type": "git", - "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "graham-campbell/result-type": "^1.1.3", - "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3", - "symfony/polyfill-ctype": "^1.24", - "symfony/polyfill-mbstring": "^1.24", - "symfony/polyfill-php80": "^1.24" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "ext-filter": "*", - "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" - }, - "suggest": { - "ext-filter": "Required to use the boolean validator." - }, - "time": "2024-07-20T21:52:34+00:00", - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - }, - "branch-alias": { - "dev-master": "5.6-dev" - } - }, - "installation-source": "source", - "autoload": { - "psr-4": { - "Dotenv\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://github.com/vlucas" - } - ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", - "keywords": [ - "dotenv", - "env", - "environment" - ], - "support": { - "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], - "install-path": "../vlucas/phpdotenv" - } - ], - "dev": true, - "dev-package-names": [] -} diff --git a/src/vendor/composer/installed.php b/src/vendor/composer/installed.php deleted file mode 100644 index 3d3f105c..00000000 --- a/src/vendor/composer/installed.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php return array( - 'root' => array( - 'name' => 'daw-iesmontsia/urban-tree', - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => 'dda517b3a94edde383dd54b01a57135aea08ebc4', - 'type' => 'project', - 'install_path' => __DIR__ . '/../../../', - 'aliases' => array(), - 'dev' => true, - ), - 'versions' => array( - 'daw-iesmontsia/urban-tree' => array( - 'pretty_version' => 'dev-main', - 'version' => 'dev-main', - 'reference' => 'dda517b3a94edde383dd54b01a57135aea08ebc4', - 'type' => 'project', - 'install_path' => __DIR__ . '/../../../', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'graham-campbell/result-type' => array( - 'pretty_version' => 'v1.1.3', - 'version' => '1.1.3.0', - 'reference' => '3ba905c11371512af9d9bdd27d99b782216b6945', - 'type' => 'library', - 'install_path' => __DIR__ . '/../graham-campbell/result-type', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'phpoption/phpoption' => array( - 'pretty_version' => '1.9.3', - 'version' => '1.9.3.0', - 'reference' => 'e3fac8b24f56113f7cb96af14958c0dd16330f54', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpoption/phpoption', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-ctype' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-ctype', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-mbstring' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-php80' => array( - 'pretty_version' => 'v1.31.0', - 'version' => '1.31.0.0', - 'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-php80', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'vlucas/phpdotenv' => array( - 'pretty_version' => 'v5.6.1', - 'version' => '5.6.1.0', - 'reference' => 'a59a13791077fe3d44f90e7133eb68e7d22eaff2', - 'type' => 'library', - 'install_path' => __DIR__ . '/../vlucas/phpdotenv', - 'aliases' => array(), - 'dev_requirement' => false, - ), - ), -); diff --git a/src/vendor/composer/platform_check.php b/src/vendor/composer/platform_check.php deleted file mode 100644 index a8b98d5c..00000000 --- a/src/vendor/composer/platform_check.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -// platform_check.php @generated by Composer - -$issues = array(); - -if (!(PHP_VERSION_ID >= 70205)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.5". You are running ' . PHP_VERSION . '.'; -} - -if ($issues) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); - } elseif (!headers_sent()) { - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; - } - } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR - ); -} From 34ae94ff68b7533390fda15763e9f837251dac31 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:58:04 +0100 Subject: [PATCH 5/9] Revert "feat(contract): add contract MVC" This reverts commit 9e30a69819bd65010c61dea714f385c04859de3f. --- src/app/Core/Logger.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/Core/Logger.php b/src/app/Core/Logger.php index fc489451..625509ba 100755 --- a/src/app/Core/Logger.php +++ b/src/app/Core/Logger.php @@ -6,12 +6,12 @@ class Logger { public static function log($message, $level = 'info') { - // $logFile = getenv("LOG_FILE_PATH"); - // $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; - // if (!file_exists($logFile)) { - // touch($logFile); - // } - // file_put_contents($logFile, $logMessage, FILE_APPEND); + $logFile = getenv("LOG_FILE_PATH"); + $logMessage = strtoupper($level) . ' - ' . date('Y-m-d H:i:s') . ' - ' . $message . PHP_EOL; + if (!file_exists($logFile)) { + touch($logFile); + } + file_put_contents($logFile, $logMessage, FILE_APPEND); } } From c142e44f8fcf8154a442d5e1fe8c48d927807cd6 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:00:14 +0100 Subject: [PATCH 6/9] Revert "feat(contract): add Contract" This reverts commit 924d495141062f7d734b542827976433c3729334. --- src/vendor/graham-campbell/result-type | 1 - src/vendor/phpoption/phpoption | 1 - src/vendor/symfony/polyfill-ctype | 1 - src/vendor/symfony/polyfill-mbstring | 1 - src/vendor/symfony/polyfill-php80 | 1 - src/vendor/vlucas/phpdotenv | 1 - 6 files changed, 6 deletions(-) delete mode 160000 src/vendor/graham-campbell/result-type delete mode 160000 src/vendor/phpoption/phpoption delete mode 160000 src/vendor/symfony/polyfill-ctype delete mode 160000 src/vendor/symfony/polyfill-mbstring delete mode 160000 src/vendor/symfony/polyfill-php80 delete mode 160000 src/vendor/vlucas/phpdotenv diff --git a/src/vendor/graham-campbell/result-type b/src/vendor/graham-campbell/result-type deleted file mode 160000 index 3ba905c1..00000000 --- a/src/vendor/graham-campbell/result-type +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3ba905c11371512af9d9bdd27d99b782216b6945 diff --git a/src/vendor/phpoption/phpoption b/src/vendor/phpoption/phpoption deleted file mode 160000 index e3fac8b2..00000000 --- a/src/vendor/phpoption/phpoption +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e3fac8b24f56113f7cb96af14958c0dd16330f54 diff --git a/src/vendor/symfony/polyfill-ctype b/src/vendor/symfony/polyfill-ctype deleted file mode 160000 index a3cc8b04..00000000 --- a/src/vendor/symfony/polyfill-ctype +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a3cc8b044a6ea513310cbd48ef7333b384945638 diff --git a/src/vendor/symfony/polyfill-mbstring b/src/vendor/symfony/polyfill-mbstring deleted file mode 160000 index 85181ba9..00000000 --- a/src/vendor/symfony/polyfill-mbstring +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 85181ba99b2345b0ef10ce42ecac37612d9fd341 diff --git a/src/vendor/symfony/polyfill-php80 b/src/vendor/symfony/polyfill-php80 deleted file mode 160000 index 60328e36..00000000 --- a/src/vendor/symfony/polyfill-php80 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 60328e362d4c2c802a54fcbf04f9d3fb892b4cf8 diff --git a/src/vendor/vlucas/phpdotenv b/src/vendor/vlucas/phpdotenv deleted file mode 160000 index a59a1379..00000000 --- a/src/vendor/vlucas/phpdotenv +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a59a13791077fe3d44f90e7133eb68e7d22eaff2 From 55db7409e635b9b08e4cadbde24a940d7ac8188e Mon Sep 17 00:00:00 2001 From: Oriol <123090161+Chuck-D-Norris@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:13:30 +0100 Subject: [PATCH 7/9] fix(contract): remove worker_id Co-authored-by: Hugoo <69076992+0x1026@users.noreply.github.com> --- docker/database/start-scripts/0-init.sql | 1 - src/app/Models/Contract.php | 19 +++---------------- src/app/Views/Contracts.php | 2 -- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 672c33a3..f24e091b 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -67,7 +67,6 @@ CREATE TABLE contracts ( start_date DATE, end_date DATE, salary DECIMAL(10, 2), - worker_id INT ); create table work_orders ( diff --git a/src/app/Models/Contract.php b/src/app/Models/Contract.php index f6b50211..98547ca3 100644 --- a/src/app/Models/Contract.php +++ b/src/app/Models/Contract.php @@ -13,7 +13,6 @@ class Contract private $start_date; private $end_date; private $salary; - private $worker_id; // Constructor per inicialitzar les propietats public function __construct($data = []) @@ -46,14 +45,13 @@ public static function findById($id) // Mètode per guardar un nou contracte public function save() { - $query = "INSERT INTO contracts (contract_type, start_date, end_date, salary, worker_id) - VALUES (:contract_type, :start_date, :end_date, :salary, :worker_id)"; + $query = "INSERT INTO contracts (contract_type, start_date, end_date, salary) + VALUES (:contract_type, :start_date, :end_date, :salary)"; $params = [ 'contract_type' => $this->contract_type, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'salary' => $this->salary, - 'worker_id' => $this->worker_id, ]; return Database::prepareAndExecute($query, $params); @@ -63,13 +61,12 @@ public function save() public function update() { $query = "UPDATE contracts SET contract_type = :contract_type, start_date = :start_date, - end_date = :end_date, salary = :salary, worker_id = :worker_id WHERE id = :id"; + end_date = :end_date, salary = :salary WHERE id = :id"; $params = [ 'contract_type' => $this->contract_type, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'salary' => $this->salary, - 'worker_id' => $this->worker_id, 'id' => $this->id, ]; @@ -109,11 +106,6 @@ public function getSalary() return $this->salary; } - public function getWorkerId() - { - return $this->worker_id; - } - public function setId($id) { $this->id = $id; @@ -138,9 +130,4 @@ public function setSalary($salary) { $this->salary = $salary; } - - public function setWorkerId($worker_id) - { - $this->worker_id = $worker_id; - } } diff --git a/src/app/Views/Contracts.php b/src/app/Views/Contracts.php index 11ad5eec..6679ad4b 100644 --- a/src/app/Views/Contracts.php +++ b/src/app/Views/Contracts.php @@ -7,7 +7,6 @@ <th class="px-4 py-2 border-b">Start Date</th> <th class="px-4 py-2 border-b">End Date</th> <th class="px-4 py-2 border-b">Salary</th> - <th class="px-4 py-2 border-b">Worker ID</th> </tr> </thead> <tbody> @@ -18,7 +17,6 @@ <td class="px-4 py-2 border-b"><?php echo $contract->getStartDate(); ?></td> <td class="px-4 py-2 border-b"><?php echo $contract->getEndDate(); ?></td> <td class="px-4 py-2 border-b"><?php echo number_format($contract->getSalary(), 2); ?></td> - <td class="px-4 py-2 border-b"><?php echo $contract->getWorkerId(); ?></td> </tr> <?php endforeach; ?> </tbody> From b82dbd282d6809dce00fd57e0b23ee4393584a7b Mon Sep 17 00:00:00 2001 From: 24Victor <118720584+24Victor@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:40:04 +0100 Subject: [PATCH 8/9] refactor(contract): improve database --- docker/database/start-scripts/0-init.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index f24e091b..3ec58b4d 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -63,10 +63,15 @@ create table workers ( CREATE TABLE contracts ( id int auto_increment primary key, - contract_type VARCHAR(255), + name varchar(255), start_date DATE, end_date DATE, - salary DECIMAL(10, 2), + invoice_proposed float, + invoice_agreed float, + invoice_paid float, + created_at timestamp default current_timestamp, + deleted_at timestamp, + updated_at timestamp, ); create table work_orders ( From b2fdde2d61ec30584917472e4a36a45735902f29 Mon Sep 17 00:00:00 2001 From: 0x1026 <69076992+0x1026@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:36:39 +0100 Subject: [PATCH 9/9] fix(contract): update changes and add seed samples --- docker/database/start-scripts/0-init.sql | 2 +- docker/database/start-scripts/1-seed.sql | 5 + src/app/Controllers/ContractController.php | 11 +- src/app/Models/Contract.php | 151 ++++----------------- src/app/Models/TreeType.php | 2 +- src/app/Views/Contracts.php | 18 ++- 6 files changed, 53 insertions(+), 136 deletions(-) diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 7131a11e..732e2d3f 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -81,7 +81,7 @@ CREATE TABLE contracts ( invoice_paid float, created_at timestamp default current_timestamp, deleted_at timestamp, - updated_at timestamp, + updated_at timestamp ); create table work_orders ( diff --git a/docker/database/start-scripts/1-seed.sql b/docker/database/start-scripts/1-seed.sql index 12c4e424..478e036e 100644 --- a/docker/database/start-scripts/1-seed.sql +++ b/docker/database/start-scripts/1-seed.sql @@ -16,3 +16,8 @@ INSERT INTO tree_types (family, genus, species) VALUES ('Pinaceae', 'Pinus', 'Pinus sylvestris'), ('Sapindaceae', 'Acer', 'Acer campestre'); +-- Insert sample contracts +INSERT INTO contracts (name, start_date, end_date, invoice_proposed, invoice_agreed, invoice_paid) VALUES +('Ayuntamiento de Valencia', '2021-01-01', '2021-12-31', 1000.00, 900.00, 900.00), +('Administración General del Estado', '2021-01-01', '2021-12-31', 2000.00, 1800.00, 1800.00), +('Ayuntamiento de Carlet', '2021-01-01', '2021-12-31', 3000.00, 2700.00, 2700.00); \ No newline at end of file diff --git a/src/app/Controllers/ContractController.php b/src/app/Controllers/ContractController.php index 7c732616..cd4388b0 100644 --- a/src/app/Controllers/ContractController.php +++ b/src/app/Controllers/ContractController.php @@ -2,14 +2,15 @@ namespace App\Controllers; +use App\Core\BaseController; use App\Core\View; use App\Models\Contract; -class ContractController +class ContractController implements BaseController { - public function index() + public function get() { - $contracts = Contract::getAll(); + $contracts = Contract::findAll(); View::render([ "view" => "Contracts", "title" => "Contracts", @@ -17,4 +18,8 @@ public function index() "data" => ["contracts" => $contracts] ]); } + + public function post() {} + public function put() {} + public function delete() {} } \ No newline at end of file diff --git a/src/app/Models/Contract.php b/src/app/Models/Contract.php index 98547ca3..6d63d922 100644 --- a/src/app/Models/Contract.php +++ b/src/app/Models/Contract.php @@ -2,132 +2,33 @@ namespace App\Models; -use App\Core\Database; -use PDO; -use PDOException; +use App\Core\BaseModel; -class Contract +class Contract extends BaseModel { - private $id; - private $contract_type; - private $start_date; - private $end_date; - private $salary; - - // Constructor per inicialitzar les propietats - public function __construct($data = []) - { - foreach ($data as $key => $value) { - $this->$key = $value; - } - } - - // Mètode per obtenir tots els contractes - public static function getAll() - { - $query = "SELECT * FROM contracts"; - $results = Database::prepareAndExecute($query); - foreach ($results as $key => $value) { - $results[$key] = new self($value); - } - return $results; - } - - // Mètode per obtenir un contracte per ID - public static function findById($id) - { - $query = "SELECT * FROM contracts WHERE id = :id"; - $results = Database::prepareAndExecute($query, ['id' => $id]); - - return $results ? new self($results[0]) : null; - } - - // Mètode per guardar un nou contracte - public function save() - { - $query = "INSERT INTO contracts (contract_type, start_date, end_date, salary) - VALUES (:contract_type, :start_date, :end_date, :salary)"; - $params = [ - 'contract_type' => $this->contract_type, - 'start_date' => $this->start_date, - 'end_date' => $this->end_date, - 'salary' => $this->salary, - ]; - - return Database::prepareAndExecute($query, $params); - } - - // Mètode per actualitzar un contracte existent - public function update() - { - $query = "UPDATE contracts SET contract_type = :contract_type, start_date = :start_date, - end_date = :end_date, salary = :salary WHERE id = :id"; - $params = [ - 'contract_type' => $this->contract_type, - 'start_date' => $this->start_date, - 'end_date' => $this->end_date, - 'salary' => $this->salary, - 'id' => $this->id, - ]; - - return Database::prepareAndExecute($query, $params); - } - - // Mètode per esborrar un contracte - public function delete() - { - $query = "DELETE FROM contracts WHERE id = :id"; - return Database::prepareAndExecute($query, ['id' => $this->id]); - } - - // Getters i setters - public function getId() - { - return $this->id; - } - - public function getContractType() - { - return $this->contract_type; - } - - public function getStartDate() - { - return $this->start_date; - } - - public function getEndDate() - { - return $this->end_date; - } - - public function getSalary() - { - return $this->salary; - } - - public function setId($id) - { - $this->id = $id; - } - - public function setContractType($contract_type) - { - $this->contract_type = $contract_type; - } - - public function setStartDate($start_date) - { - $this->start_date = $start_date; - } - - public function setEndDate($end_date) - { - $this->end_date = $end_date; - } - - public function setSalary($salary) - { - $this->salary = $salary; + public $name; + public $start_date; + public $end_date; + public $invoice_proposed; + public $invoice_agreed; + public $invoice_paid; + public $created_at; + + protected static function getTableName() + { + return 'contracts'; + } + + protected static function mapDataToModel($data) { + $contract = new Contract(); + $contract->id = $data['id']; + $contract->name = $data['name']; + $contract->start_date = $data['start_date']; + $contract->end_date = $data['end_date']; + $contract->invoice_proposed = $data['invoice_proposed']; + $contract->invoice_agreed = $data['invoice_agreed']; + $contract->invoice_paid = $data['invoice_paid']; + $contract->created_at = $data['created_at']; + return $contract; } } diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php index e59f8f1f..359a9d20 100644 --- a/src/app/Models/TreeType.php +++ b/src/app/Models/TreeType.php @@ -10,7 +10,7 @@ class TreeType extends BaseModel public string $genus; public string $species; - protected static function getTableName(): string + protected static function getTableName() { return 'tree_types'; } diff --git a/src/app/Views/Contracts.php b/src/app/Views/Contracts.php index 6679ad4b..021129a3 100644 --- a/src/app/Views/Contracts.php +++ b/src/app/Views/Contracts.php @@ -3,20 +3,26 @@ <thead> <tr class="bg-gray-100 text-left"> <th class="px-4 py-2 border-b">ID</th> - <th class="px-4 py-2 border-b">Contract Type</th> + <th class="px-4 py-2 border-b">Name</th> <th class="px-4 py-2 border-b">Start Date</th> <th class="px-4 py-2 border-b">End Date</th> - <th class="px-4 py-2 border-b">Salary</th> + <th class="px-4 py-2 border-b">Invoice proposed</th> + <th class="px-4 py-2 border-b">Invoice agreed</th> + <th class="px-4 py-2 border-b">Invoice paid</th> + <th class="px-4 py-2 border-b">Created at</th> </tr> </thead> <tbody> <?php foreach ($contracts as $contract): ?> <tr class="hover:bg-gray-50"> <td class="px-4 py-2 border-b"><?php echo $contract->getId(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $contract->getContractType(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $contract->getStartDate(); ?></td> - <td class="px-4 py-2 border-b"><?php echo $contract->getEndDate(); ?></td> - <td class="px-4 py-2 border-b"><?php echo number_format($contract->getSalary(), 2); ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->name; ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->start_date; ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->end_date; ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->invoice_proposed; ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->invoice_agreed; ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->invoice_paid; ?></td> + <td class="px-4 py-2 border-b"><?php echo $contract->created_at; ?></td> </tr> <?php endforeach; ?> </tbody>