From a1758639ec7b1339679da63ca1a84e727c296e10 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Mon, 9 Oct 2023 23:05:28 +0000 Subject: [PATCH 01/43] Updated dependencies. --- .devcontainer/devcontainer.json | 94 ++++++++++ .vscode/extensions.json | 70 +++++++ .vscode/settings.json | 320 ++++++++++++++++++++++++++++++++ composer.json | 4 +- docker-compose.yml | 59 ++++++ phpunit.xml | 2 +- phpunit.xml.dist | 2 +- 7 files changed, 547 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..016cf017 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,94 @@ +// https://aka.ms/devcontainer.json +{ + "name": "Existing Docker Compose (Extend)", + "dockerComposeFile": [ + "../docker-compose.yml" + ], + "features": { + "ghcr.io/devcontainers/features/sshd:1": { + "version": "latest" + } + }, + "service": "laravel.test", + "workspaceFolder": "/var/www/html", + "customizations": { + "vscode": { + "settings": {}, + "extensions": [ + "aaron-bond.better-comments", + "adrianwilczynski.alpine-js-intellisense", + "amiralizadeh9480.laravel-extra-intellisense", + "austenc.laravel-blade-spacer", + "beyondcode.tinkerwell", + "bmewburn.vscode-intelephense-client", + "bradlc.vscode-tailwindcss", + "christian-kohler.npm-intellisense", + "christian-kohler.path-intellisense", + "cierra.livewire-vscode", + "codingyu.laravel-goto-view", + "davidanson.vscode-markdownlint", + "davidbwaters.macos-modern-theme", + "eamodio.gitlens", + "ecodes.vscode-phpmd@1.2.0", + "editorconfig.editorconfig", + "ericcheng.codesongclear", + "faelv.composer-companion", + "file-icons.file-icons", + "foxundermoon.shell-format", + "georgykurian.laravel-ide-helper", + "github.codespaces", + "GitHub.copilot-chat", + "GitHub.copilot-nightly", + "github.vscode-github-actions", + "github.vscode-pull-request-github", + "Gruntfuggly.activitusbar", + "heissenbergerlab.php-array-from-json", + "heybourn.headwind", + "huibizhang.codesnap-plus", + "irongeek.vscode-env", + "kencocaceo.customvscodeuicss", + "m4ns0ur.base64", + "maciejdems.add-to-gitignore", + "mahmoudshahin.laravel-routes", + "markis.code-coverage", + "martybegood.single-editor-tabs", + "mechatroner.rainbow-csv", + "mehedidracula.php-namespace-resolver", + "mhutchie.git-graph", + "mikestead.dotenv", + "mohamedbenhida.laravel-intellisense", + "mrmlnc.vscode-duplicate", + "naoray.laravel-goto-components", + "oderwat.indent-rainbow", + "pcbowers.alpine-intellisense", + "recca0120.vscode-phpunit", + "redhat.vscode-yaml", + "rifi2k.format-html-in-php", + "shevaua.phpcs", + "shufo.vscode-blade-formatter", + "sperovita.alpinejs-syntax-highlight", + "streetsidesoftware.code-spell-checker", + "syler.ignore", + "teabyii.ayu", + "usernamehw.errorlens", + "vincaslt.highlight-matching-tag", + "WakaTime.vscode-wakatime", + "withfig.fig", + "wongjn.php-sniffer", + "xdebug.php-debug", + "codecov.codecov" + ] + } + }, + "remoteUser": "sail", + "postCreateCommand": "sudo chown -R 1000:1000 /var/www/html", + // "forwardPorts": [ + // ], + // "portsAttributes": { + // }, + "mounts": [ + "source=${localEnv:HOME}/.wakatime.cfg,target=/home/sail/.wakatime.cfg,type=bind,consistency=delegated" + ] + // "runServices": [], + // "shutdownAction": "none", +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..db7c0782 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,70 @@ +{ + "recommendations": [ + "aaron-bond.better-comments", + "adrianwilczynski.alpine-js-intellisense", + "amiralizadeh9480.laravel-extra-intellisense", + "austenc.laravel-blade-spacer", + "beyondcode.tinkerwell", + "bmewburn.vscode-intelephense-client", + "bradlc.vscode-tailwindcss", + "christian-kohler.npm-intellisense", + "christian-kohler.path-intellisense", + "cierra.livewire-vscode", + "codingyu.laravel-goto-view", + "davidanson.vscode-markdownlint", + "davidbwaters.macos-modern-theme", + "eamodio.gitlens", + "ecodes.vscode-phpmd@1.2.0", + "editorconfig.editorconfig", + "ericcheng.codesongclear", + "faelv.composer-companion", + "file-icons.file-icons", + "foxundermoon.shell-format", + "georgykurian.laravel-ide-helper", + "github.codespaces", + "GitHub.copilot-chat", + "GitHub.copilot-nightly", + "github.vscode-github-actions", + "github.vscode-pull-request-github", + "Gruntfuggly.activitusbar", + "heissenbergerlab.php-array-from-json", + "heybourn.headwind", + "huibizhang.codesnap-plus", + "irongeek.vscode-env", + "kencocaceo.customvscodeuicss", + "m4ns0ur.base64", + "maciejdems.add-to-gitignore", + "mahmoudshahin.laravel-routes", + "markis.code-coverage", + "martybegood.single-editor-tabs", + "mechatroner.rainbow-csv", + "mehedidracula.php-namespace-resolver", + "mhutchie.git-graph", + "mikestead.dotenv", + "mohamedbenhida.laravel-intellisense", + "mrmlnc.vscode-duplicate", + "naoray.laravel-goto-components", + "oderwat.indent-rainbow", + "pcbowers.alpine-intellisense", + "recca0120.vscode-phpunit", + "redhat.vscode-yaml", + "rifi2k.format-html-in-php", + "shevaua.phpcs", + "shufo.vscode-blade-formatter", + "sperovita.alpinejs-syntax-highlight", + "streetsidesoftware.code-spell-checker", + "syler.ignore", + "teabyii.ayu", + "usernamehw.errorlens", + "vincaslt.highlight-matching-tag", + "WakaTime.vscode-wakatime", + "withfig.fig", + "wongjn.php-sniffer", + "xdebug.php-debug", + "codecov.codecov" + ], + "unwantedRecommendations": [ + "ikappas.phpcs", + "linyang95.phpmd" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..184d6e29 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,320 @@ +{ + "activitusbar.combineWorkspaceSettings": true, + "activitusbar.searchViewInPanel": false, + "activitusbar.showSourceControlCounter": true, + "activitusbar.views": [ + { + "name": "command.workbench.panel.chatSidebar.copilot", + "codicon": "octoface" + }, + { + "name": "explorer", + "codicon": "explorer-view-icon" + }, + { + "name": "search", + "codicon": "search-view-icon" + }, + { + "name": "pr:github", + "codicon": "github" + }, + { + "name": "scm", + "codicon": "source-control-view-icon" + }, + { + "name": "command.workbench.panel.chatSidebar.copilot", + "codicon": "octoface" + }, + { + "name": "debug", + "codicon": "run-view-icon" + }, + { + "name": "github.codespaces.explorer", + "codicon": "remote-explorer" + }, + { + "name": "extensions", + "codicon": "extensions-view-icon" + }, + { + "codicon": "kebab-vertical" + } + ], + "alpine-intellisense.settings.languageScopes": "html,blade,php", + "better-comments.tags": [ + { + "tag": "!", + "color": "#FF2D00", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "?", + "color": "#3498DB", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "//", + "color": "#474747", + "strikethrough": true, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "todo", + "color": "#FF8C00", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + }, + { + "tag": "*", + "color": "#98C379", + "strikethrough": false, + "underline": false, + "backgroundColor": "transparent", + "bold": false, + "italic": false + } + ], + "blade.format.enable": true, + "blade.newLine": true, + "bladeFormatter.format.enabled": true, + "bladeFormatter.format.noMultipleEmptyLines": true, + "bladeFormatter.format.sortHtmlAttributes": "alphabetical", + "bladeFormatter.format.sortTailwindcssClasses": true, + "bladeFormatter.format.wrapAttributes": "force-expand-multiline", + "bladeFormatter.format.wrapLineLength": 100, + "breadcrumbs.enabled": true, + "composerCompanion.executablePath": "composer", + "cSpell.spellCheckOnlyWorkspaceFiles": true, + "cSpell.autoFormatConfigFile": true, + "css.validate": false, + "debug.allowBreakpointsEverywhere": true, + "debug.showBreakpointsInOverviewRuler": true, + "diffEditor.ignoreTrimWhitespace": false, + "diffEditor.wordWrap": "off", + "editor.acceptSuggestionOnEnter": "off", + "editor.accessibilitySupport": "off", + "editor.autoClosingBrackets": "always", + "editor.codeLensFontFamily": "JetBrains Mono", + "editor.cursorBlinking": "expand", + "editor.cursorSmoothCaretAnimation": "on", + "editor.detectIndentation": true, + "editor.emptySelectionClipboard": false, + "editor.fontFamily": "JetBrains Mono", + "editor.fontLigatures": true, + "editor.formatOnPaste": false, + "editor.formatOnType": true, + "editor.gotoLocation.multipleDeclarations": "goto", + "editor.gotoLocation.multipleDefinitions": "goto", + "editor.gotoLocation.multipleImplementations": "goto", + "editor.gotoLocation.multipleReferences": "goto", + "editor.gotoLocation.multipleTypeDefinitions": "goto", + "editor.inlayHints.fontFamily": "JetBrains Mono", + "editor.inlineSuggest.enabled": true, + "editor.insertSpaces": true, + "editor.lightbulb.enabled": false, + "editor.linkedEditing": true, + "editor.minimap.maxColumn": 100, + "editor.parameterHints.enabled": false, + "editor.quickSuggestions": { + "strings": true + }, + "editor.renderFinalNewline": "on", + "editor.renderWhitespace": "none", + "editor.roundedSelection": true, + "editor.rulers": [ + 100, + ], + "editor.stickyScroll.enabled": true, + "editor.suggest.localityBonus": true, + "editor.suggest.showValues": false, + "editor.trimAutoWhitespace": true, + "editor.wordBasedSuggestions": false, + "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?", + "editor.wordWrapColumn": 100, + "editor.wrappingIndent": "none", + "errorLens.enableOnDiffView": true, + "errorLens.fontFamily": "JetBrains Mono", + "errorLens.messageTemplate": "$message $source $code", + "explorer.confirmDelete": false, + "explorer.confirmDragAndDrop": false, + "extensions.ignoreRecommendations": false, + "files.autoGuessEncoding": true, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true, + "git.allowForcePush": true, + "git.autofetch": true, + "git.confirmSync": false, + "git.enableCommitSigning": true, + "git.enableSmartCommit": true, + "git.fetchOnPull": true, + "git.ignoreRebaseWarning": true, + "git.mergeEditor": false, + "git.showPushSuccessNotification": true, + "github.copilot.enable": { + "*": true, + "yaml": false, + "plaintext": false, + "markdown": false + }, + "github.copilot.inlineSuggest.enable": true, + "githubIssues.issueBranchTitle": "${user}/${sanitizedIssueTitle}", + "githubIssues.queries": [ + { + "label": "My Issues", + "query": "default" + }, + { + "label": "Created Issues", + "query": "author:${user} state:open repo:${owner}\/${repository} sort:created-desc" + }, + { + "label": "Recent Issues", + "query": "state:open repo:${owner}\/${repository} sort:updated-desc" + } + ], + "githubIssues.workingIssueFormatScm": "", + "githubPullRequests.assignCreated": "${user}", + "githubPullRequests.createDraft": true, + "githubPullRequests.defaultMergeMethod": "squash", + "githubPullRequests.fileListLayout": "tree", + "githubPullRequests.ignoredPullRequestBranches": [ + "develop", + "master" + ], + "githubPullRequests.pullBranch": "never", + "githubPullRequests.showPullRequestNumberInTree": true, + "githubPullRequests.terminalLinksHandler": "vscode", + "gitlens.showWelcomeOnInstall": false, + "gitlens.showWhatsNewAfterUpgrades": false, + "gitlens.outputLevel": "silent", + "gitlens.plusFeatures.enabled": false, + "gitlens.virtualRepositories.enabled": false, + "gitlens.codeLens.enabled": false, + "gitlens.codeLens.recentChange.enabled": false, + "gitlens.codeLens.authors.enabled": false, + "gitlens.statusBar.enabled": false, + "gitlens.statusBar.pullRequests.enabled": false, + "gitlens.hovers.enabled": false, + "gitlens.hovers.avatars": false, + "gitlens.hovers.pullRequests.enabled": false, + "gitlens.hovers.autolinks.enabled": false, + "gitlens.hovers.currentLine.enabled": false, + "gitlens.hovers.autolinks.enhanced": false, + "gitlens.hovers.currentLine.details": false, + "gitlens.hovers.currentLine.changes": false, + "gitlens.hovers.annotations.enabled": false, + "gitlens.hovers.annotations.changes": false, + "gitlens.hovers.annotations.details": false, + "headwind.runOnSave": true, + "html.format.indentHandlebars": true, + "html.format.indentInnerHtml": true, + "html.format.preserveNewLines": true, + "html.format.wrapAttributes": "force", + "html.format.wrapLineLength": 100, + "indentRainbow.colorOnWhiteSpaceOnly": true, + "intelephense.environment.documentRoot": "public/index.php", + "intelephense.files.exclude": [ + "**/.git/**", + "**/.svn/**", + "**/.hg/**", + "**/CVS/**", + "**/.DS_Store/**", + "**/node_modules/**", + "**/bower_components/**", + "**/vendor/**/{Tests,tests}/**", + "**/.history/**" + ], + "intelephense.phpdoc.returnVoid": false, + "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true, + "LaravelExtraIntellisense.modelAccessorCase": "camel", + "LaravelExtraIntellisense.modelAttributeCase": "camel", + "LaravelExtraIntellisense.modelsPaths": [ + "app", + "app/Models" + ], + "LaravelExtraIntellisense.modelVariables": { + "user": "App\\Models\\User" + }, + "LaravelIntellisense.model": "App\\Models", + "markdown.preview.fontFamily": "JetBrains Mono", + "markdownlint.config": { + "default": true, + "MD024": false, + "MD022": false, + "MD032": false, + }, + "namespaceResolver.leadingSeparator": false, + "namespaceResolver.showMessageOnStatusBar": true, + "namespaceResolver.sortAlphabetically": true, + "namespaceResolver.sortOnSave": true, + "php.suggest.basic": false, + "php.validate.enable": false, + "php.validate.run": "onType", + "phpcs.executablePath": "vendor/bin/phpcs", + "phpcs.showSources": true, + "phpmd.rules": "phpmd.xml", + "phpmd.command": "vendor/bin/phpmd", + "phpmd.verbose": true, + "phpunit.args": [ + "--coverage-clover=coverage.xml", + ], + "redhat.telemetry.enabled": false, + "search.exclude": { + // Hide everything in /vendor, except "laravel" and "livewire" folders. + "**/vendor/{[^l],?[^ai]}*": true, + // Hide everything in /public, except "index.php" + "**/public/{[^i],?[^n]}*": true, + "**/node_modules": true, + "**/dist": true, + "**/_ide_helper.php": true, + "**/composer.lock": true, + "**/package-lock.json": true, + "storage": true, + ".phpunit.result.cache": true + }, + "tailwindCSS.validate": true, + "terminal.explorerKind": "external", + "terminal.integrated.drawBoldTextInBrightColors": false, + "terminal.integrated.enableMultiLinePasteWarning": false, + "terminal.integrated.fontFamily": "MesloLGS NF", + "terminal.integrated.gpuAcceleration": "off", + "terminal.integrated.scrollback": 5000, + "typescript.suggest.enabled": false, + "window.commandCenter": true, + "workbench.editor.enablePreview": false, + "workbench.editor.showIcons": false, + "workbench.editor.showTabs": false, + "workbench.editor.tabCloseButton": "left", + "workbench.fontAliasing": "auto", + "workbench.iconTheme": "file-icons", + "workbench.productIconTheme": "macos-modern", + "workbench.startupEditor": "none", + "zenMode.fullScreen": false, + "zenMode.hideLineNumbers": false, + // formaters + "[blade]": { + "editor.defaultFormatter": "shufo.vscode-blade-formatter" + }, + "[php]": { + "editor.defaultFormatter": "bmewburn.vscode-intelephense-client" + }, + "window.title": "totality" +} \ No newline at end of file diff --git a/composer.json b/composer.json index 0460718b..8bba5cb9 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": "^8.1", + "php": ">=8.1", "genealabs/laravel-pivot-events": "^10.0", "illuminate/cache": "^10.0", "illuminate/config": "^10.0", @@ -28,7 +28,7 @@ "require-dev": { "doctrine/dbal": "^3.3", "fakerphp/faker": "^1.11", - "laravel/nova": "^3.9", + "laravel/nova": "^4.0", "orchestra/testbench-browser-kit": "^8.0", "orchestra/testbench": "^8.0", "php-coveralls/php-coveralls" : "^2.2", diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..91897e8c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,59 @@ +# For more information: https://laravel.com/docs/sail +version: '3' +services: + laravel.test: + image: ghcr.io/mikebronner/sail/php-8.2:latest + extra_hosts: + - 'host.docker.internal:host-gateway' + ports: + - '${APP_PORT:-80}:80' + - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' + environment: + WWWUSER: '${WWWUSER}' + LARAVEL_SAIL: 1 + XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' + XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' + volumes: + - '.:/var/www/html' + networks: + - sail + depends_on: + - redis + pgsql: + image: 'postgres:15' + ports: + - '${FORWARD_DB_PORT:-5432}:5432' + environment: + PGPASSWORD: '${DB_PASSWORD:-secret}' + POSTGRES_DB: '${DB_DATABASE:-testing}' + POSTGRES_USER: '${DB_USERNAME:-forge}' + POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}' + volumes: + - 'sail-pgsql:/var/lib/postgresql/data' + - './vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql' + networks: + - sail + healthcheck: + test: ["CMD", "pg_isready", "-q", "-d", "${DB_DATABASE}", "-U", "${DB_USERNAME}"] + retries: 3 + timeout: 5s + redis: + image: 'redis:alpine' + ports: + - '${FORWARD_REDIS_PORT:-6379}:6379' + volumes: + - 'sail-redis:/data' + networks: + - sail + healthcheck: + test: ["CMD", "redis-cli", "ping"] + retries: 3 + timeout: 5s +networks: + sail: + driver: bridge +volumes: + sail-pgsql: + driver: local + sail-redis: + driver: local diff --git a/phpunit.xml b/phpunit.xml index 638c1866..97287865 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -25,7 +25,7 @@ - + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3c8ff2dd..5e696c73 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -35,7 +35,7 @@ - + From 6045f3da035877369e44f31a4898459d536b7be9 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Tue, 10 Oct 2023 01:06:30 +0000 Subject: [PATCH 02/43] Brought tests back to green. --- phpunit.xml | 6 +-- phpunit.xml.dist | 41 ------------------- .../CachedBuilder/WhereJsonContainsTest.php | 4 +- 3 files changed, 5 insertions(+), 46 deletions(-) delete mode 100644 phpunit.xml.dist diff --git a/phpunit.xml b/phpunit.xml index 97287865..aad85dd9 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,16 +19,16 @@ - + - + - + diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 5e696c73..00000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,41 +0,0 @@ - - - - - ./tests/Feature - - - ./tests/Integration - - - ./tests/Nova - - - - - ./src - - - - - - - - - - - - - - - diff --git a/tests/Integration/CachedBuilder/WhereJsonContainsTest.php b/tests/Integration/CachedBuilder/WhereJsonContainsTest.php index 0d4edc56..41d164c8 100644 --- a/tests/Integration/CachedBuilder/WhereJsonContainsTest.php +++ b/tests/Integration/CachedBuilder/WhereJsonContainsTest.php @@ -14,9 +14,9 @@ protected function getEnvironmentSetUp($app) parent::getEnvironmentSetUp($app); $app['config']->set('database.default', 'pgsql'); - $app['config']->set('database.connections.pgsql.host', env("PGSQL_HOST", "127.0.0.1")); + $app['config']->set('database.connections.pgsql.host', env("PGSQL_HOST", "pgsql")); $app['config']->set('database.connections.pgsql.database', env("PGSQL_DATABASE", "testing")); - $app['config']->set('database.connections.pgsql.username', env("PGSQL_USERNAME", "homestead")); + $app['config']->set('database.connections.pgsql.username', env("PGSQL_USERNAME", "forge")); $app['config']->set('database.connections.pgsql.password', env("PGSQL_PASSWORD", "secret")); } From cb83f9553ece0d2563d328ac796df89e0b3fac0b Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 23 Dec 2023 18:03:26 +0000 Subject: [PATCH 03/43] Updated codespace configuration. --- .devcontainer/devcontainer.json | 17 +++++--- .editorconfig | 19 +++++++++ .github/workflows/laravel.yml | 2 +- .gitignore | 6 +-- .vscode/extensions.json | 3 +- .vscode/settings.json | 12 +++--- composer.json | 3 +- phpmd.xml | 47 --------------------- phpunit.xml | 75 +++++++++++++++++++-------------- tools/phpcs | 1 - tools/phpmd | 1 - tools/phpunit | 1 - 12 files changed, 85 insertions(+), 102 deletions(-) create mode 100644 .editorconfig delete mode 100644 phpmd.xml delete mode 120000 tools/phpcs delete mode 120000 tools/phpmd delete mode 120000 tools/phpunit diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 016cf017..eaac2e1e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,7 +29,6 @@ "davidanson.vscode-markdownlint", "davidbwaters.macos-modern-theme", "eamodio.gitlens", - "ecodes.vscode-phpmd@1.2.0", "editorconfig.editorconfig", "ericcheng.codesongclear", "faelv.composer-companion", @@ -82,10 +81,18 @@ }, "remoteUser": "sail", "postCreateCommand": "sudo chown -R 1000:1000 /var/www/html", - // "forwardPorts": [ - // ], - // "portsAttributes": { - // }, + "forwardPorts": [ + 5432, + 6379 + ], + "portsAttributes": { + "5432": { + "label": "Postgres" + }, + "6379": { + "label": "Redis" + } + }, "mounts": [ "source=${localEnv:HOME}/.wakatime.cfg,target=/home/sail/.wakatime.cfg,type=bind,consistency=delegated" ] diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..bc1105dc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false +indent_size = 2 + +[*.{yml,yaml}] +indent_size = 2 + +[.blackfire.yaml] +indent_size = 4 diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index a169f2bb..35899136 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -42,7 +42,7 @@ jobs: - uses: harmon758/postgresql-action@v1 with: - postgresql version: '11' + postgresql version: '15' postgresql db: 'testing' postgresql user: 'homestead' postgresql password: 'secret' diff --git a/.gitignore b/.gitignore index c2d4570f..8fbb4834 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ +.idea +.phpunit.result.cache +/.phpunit* /build /vendor composer.lock -.phpunit.result.cache -phpunit.xml -.idea diff --git a/.vscode/extensions.json b/.vscode/extensions.json index db7c0782..757b5a7d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -14,7 +14,6 @@ "davidanson.vscode-markdownlint", "davidbwaters.macos-modern-theme", "eamodio.gitlens", - "ecodes.vscode-phpmd@1.2.0", "editorconfig.editorconfig", "ericcheng.codesongclear", "faelv.composer-companion", @@ -67,4 +66,4 @@ "ikappas.phpcs", "linyang95.phpmd" ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 184d6e29..315d6332 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -145,7 +145,7 @@ "editor.suggest.localityBonus": true, "editor.suggest.showValues": false, "editor.trimAutoWhitespace": true, - "editor.wordBasedSuggestions": false, + "editor.wordBasedSuggestions": "off", "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?", "editor.wordWrapColumn": 100, "editor.wrappingIndent": "none", @@ -270,9 +270,6 @@ "php.validate.run": "onType", "phpcs.executablePath": "vendor/bin/phpcs", "phpcs.showSources": true, - "phpmd.rules": "phpmd.xml", - "phpmd.command": "vendor/bin/phpmd", - "phpmd.verbose": true, "phpunit.args": [ "--coverage-clover=coverage.xml", ], @@ -301,7 +298,7 @@ "window.commandCenter": true, "workbench.editor.enablePreview": false, "workbench.editor.showIcons": false, - "workbench.editor.showTabs": false, + "workbench.editor.showTabs": "single", "workbench.editor.tabCloseButton": "left", "workbench.fontAliasing": "auto", "workbench.iconTheme": "file-icons", @@ -316,5 +313,6 @@ "[php]": { "editor.defaultFormatter": "bmewburn.vscode-intelephense-client" }, - "window.title": "totality" -} \ No newline at end of file + "window.title": "totality", + "workbench.editor.tabActionLocation": "left" +} diff --git a/composer.json b/composer.json index 8bba5cb9..68e81339 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,7 @@ "orchestra/testbench-browser-kit": "^8.0", "orchestra/testbench": "^8.0", "php-coveralls/php-coveralls" : "^2.2", - "phpmd/phpmd": "^2.11", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^10.0", "slevomat/coding-standard": "^7.0", "squizlabs/php_codesniffer": "^3.6", "symfony/thanks": "^1.2", diff --git a/phpmd.xml b/phpmd.xml deleted file mode 100644 index 45449165..00000000 --- a/phpmd.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - Custom ruleset for Laravel. - - - - - - - - - - - - - - - - - 36 - - - - - - - 2 - - - - - - - 2 - - - - - - diff --git a/phpunit.xml b/phpunit.xml index aad85dd9..eeb38981 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,34 +1,45 @@ - - - - ./src - - - - - ./tests/Feature - - - ./tests/Integration - - - ./tests/Nova - - - - - - - - - - - - - - - - - + + + + + ./tests/Feature + + + ./tests/Integration + + + ./tests/Nova + + + + + + + + + + + + + + + + + + + + ./src + + diff --git a/tools/phpcs b/tools/phpcs deleted file mode 120000 index 9a822ebb..00000000 --- a/tools/phpcs +++ /dev/null @@ -1 +0,0 @@ -/home/forge/.phive/phars/phpcs-3.5.6.phar \ No newline at end of file diff --git a/tools/phpmd b/tools/phpmd deleted file mode 120000 index 7649801a..00000000 --- a/tools/phpmd +++ /dev/null @@ -1 +0,0 @@ -/home/forge/.phive/phars/phpmd-2.7.0.phar \ No newline at end of file diff --git a/tools/phpunit b/tools/phpunit deleted file mode 120000 index c8a2e31f..00000000 --- a/tools/phpunit +++ /dev/null @@ -1 +0,0 @@ -/home/forge/.phive/phars/phpunit-9.3.10.phar \ No newline at end of file From 93a013cb2785d0e4c11e6f43233e84d12a914d7e Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 23 Dec 2023 18:03:37 +0000 Subject: [PATCH 04/43] WIP --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 315d6332..66f1adce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -162,7 +162,7 @@ "git.allowForcePush": true, "git.autofetch": true, "git.confirmSync": false, - "git.enableCommitSigning": true, + "git.enableCommitSigning": false, "git.enableSmartCommit": true, "git.fetchOnPull": true, "git.ignoreRebaseWarning": true, From 4e70c9722464b5b95add471a5dbb1dd58b9a0986 Mon Sep 17 00:00:00 2001 From: Peter Brennan Date: Sun, 24 Dec 2023 04:26:40 +1000 Subject: [PATCH 05/43] Update CacheKey.php (#456) BUG FIX --- src/CacheKey.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CacheKey.php b/src/CacheKey.php index fe3913b7..d8ae7af8 100644 --- a/src/CacheKey.php +++ b/src/CacheKey.php @@ -411,7 +411,7 @@ protected function recursiveImplode(array $items, string $glue = ",") : string return $result; } - private function processEnum(\BackedEnum|\UnitEnum|Expression|string $value): string + private function processEnum(\BackedEnum|\UnitEnum|Expression|string|null $value): string|null { if ($value instanceof \BackedEnum) { return $value->value; From b952d5e02ce8d0e723a6b076bab3af1587399e18 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 23 Dec 2023 18:40:52 +0000 Subject: [PATCH 06/43] Cleaned up code. --- src/CacheKey.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/CacheKey.php b/src/CacheKey.php index fe3913b7..60d90822 100644 --- a/src/CacheKey.php +++ b/src/CacheKey.php @@ -1,5 +1,8 @@ -expressionToString($where["first"]); } @@ -179,7 +183,7 @@ protected function getOrderByClauses() : string } $orders = collect($this->query->orders); - + return $orders ->reduce(function ($carry, $order) { if (($order["type"] ?? "") === "Raw") { @@ -225,7 +229,7 @@ protected function getQueryColumns(array $columns) : string if (property_exists($this->query, "columns") && $this->query->columns ) { - $columns = array_map(function ($column) { + $columns = array_map(function ($column) { return $this->expressionToString($column); }, $this->query->columns); @@ -350,7 +354,7 @@ protected function getWhereClauses(array $wheres = []) : string return $value; }); } - + protected function getWheres(array $wheres) : Collection { $wheres = collect($wheres); @@ -384,7 +388,7 @@ protected function getWithModels() : string return "{$carry}-{$relatedConnection}:{$relatedDatabase}:{$related}"; }); } - + protected function recursiveImplode(array $items, string $glue = ",") : string { $result = ""; @@ -411,11 +415,11 @@ protected function recursiveImplode(array $items, string $glue = ",") : string return $result; } - private function processEnum(\BackedEnum|\UnitEnum|Expression|string $value): string + private function processEnum(BackedEnum|UnitEnum|Expression|string|null $value): ?string { - if ($value instanceof \BackedEnum) { + if ($value instanceof BackedEnum) { return $value->value; - } elseif ($value instanceof \UnitEnum) { + } elseif ($value instanceof UnitEnum) { return $value->name; } elseif ($value instanceof Expression) { return $this->expressionToString($value); From 3228a1825d82c0fcd21d88613f121240c9c7141f Mon Sep 17 00:00:00 2001 From: jamesRUS52 <39707635+jamesRUS52@users.noreply.github.com> Date: Sat, 23 Dec 2023 21:46:19 +0300 Subject: [PATCH 07/43] JsonContainsKey supported (#454) --- src/CacheKey.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CacheKey.php b/src/CacheKey.php index 60d90822..4706655e 100644 --- a/src/CacheKey.php +++ b/src/CacheKey.php @@ -271,7 +271,7 @@ protected function getTableSlug() : string protected function getTypeClause($where) : string { - $type = in_array($where["type"], ["InRaw", "In", "NotIn", "Null", "NotNull", "between", "NotInSub", "InSub", "JsonContains", "Fulltext"]) + $type = in_array($where["type"], ["InRaw", "In", "NotIn", "Null", "NotNull", "between", "NotInSub", "InSub", "JsonContains", "Fulltext", "JsonContainsKey"]) ? strtolower($where["type"]) : strtolower($where["operator"]); From 650e20d74b2c97448a132ea3dea25f1c9e07e5e3 Mon Sep 17 00:00:00 2001 From: Axel Date: Sat, 23 Dec 2023 19:49:59 +0100 Subject: [PATCH 08/43] Add expressionToString to getOtherClauses (#451) --- src/CacheKey.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CacheKey.php b/src/CacheKey.php index 4706655e..a7ff568d 100644 --- a/src/CacheKey.php +++ b/src/CacheKey.php @@ -210,6 +210,11 @@ protected function getOtherClauses(array $where) : string $value .= $this->getValuesClause($where); $column = ""; + + if (data_get($where, "column") instanceof Expression) { + $where["column"] = $this->expressionToString(data_get($where, "column")); + } + $column .= isset($where["column"]) ? $where["column"] : ""; $column .= isset($where["columns"]) ? implode("-", $where["columns"]) : ""; From 19bcdf2aa9b635e1c6ae034599c393366d5c8618 Mon Sep 17 00:00:00 2001 From: Charlie Waddell Date: Sat, 23 Dec 2023 18:53:05 +0000 Subject: [PATCH 09/43] Having clauses missing from the generated CacheKey (#403) --- src/CacheKey.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/CacheKey.php b/src/CacheKey.php index a7ff568d..057582f0 100644 --- a/src/CacheKey.php +++ b/src/CacheKey.php @@ -51,6 +51,7 @@ public function make( $key .= $this->getIdColumn($idColumn ?: ""); $key .= $this->getQueryColumns($columns); $key .= $this->getWhereClauses(); + $key .= $this->getHavingClauses(); $key .= $this->getWithModels(); $key .= $this->getOrderByClauses(); $key .= $this->getOffsetClause(); @@ -58,7 +59,7 @@ public function make( $key .= $this->getBindingsSlug(); $key .= $keyDifferentiator; $key .= $this->macroKey; -// dump($key); + return $key; } @@ -101,6 +102,27 @@ protected function getCurrentBinding(string $type, $bindingFallback = null) return data_get($this->query->bindings, "{$type}.{$this->currentBinding}", $bindingFallback); } + protected function getHavingClauses() + { + return Collection::make($this->query->havings)->reduce(function ($carry, $having) { + $value = $carry; + $value .= $this->getHavingClause($having); + + return $value; + }); + } + + protected function getHavingClause(array $having): string + { + $return = '-having'; + + foreach ($having as $key => $value) { + $return .= '_' . $key . '_' . str_replace(' ', '_', $value); + } + + return $return; + } + protected function getIdColumn(string $idColumn) : string { return $idColumn ? "_{$idColumn}" : ""; From 15bccaa066086b68e7430663d07c293ead274d8e Mon Sep 17 00:00:00 2001 From: Kieran Anderson Date: Sun, 25 Feb 2024 05:04:28 +0000 Subject: [PATCH 10/43] Ensure isCacheable in checkCooldownAndFlushAfterPersisting --- src/Traits/Caching.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php index 5d5fccb9..7762a593 100644 --- a/src/Traits/Caching.php +++ b/src/Traits/Caching.php @@ -263,6 +263,10 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance) protected function checkCooldownAndFlushAfterPersisting(Model $instance, string $relationship = "") { + if (!$this->isCachable()) { + return; + } + [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance); if (! $cacheCooldown) { @@ -295,6 +299,10 @@ public function isCachable() : bool $isCacheDisabled = ! Container::getInstance() ->make("config") ->get("laravel-model-caching.enabled"); + if ($isCacheDisabled) { + return false; + } + $allRelationshipsAreCachable = true; if ( @@ -327,7 +335,6 @@ public function isCachable() : bool } return $this->isCachable - && ! $isCacheDisabled && $allRelationshipsAreCachable; } From c90c9c56fbab05334c7b109a3ab56fd044c69d97 Mon Sep 17 00:00:00 2001 From: Shift Date: Tue, 27 Feb 2024 01:21:31 +0000 Subject: [PATCH 11/43] Bump dependencies for Laravel 11 --- composer.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 68e81339..dd32aafe 100644 --- a/composer.json +++ b/composer.json @@ -17,23 +17,23 @@ "require": { "php": ">=8.1", "genealabs/laravel-pivot-events": "^10.0", - "illuminate/cache": "^10.0", - "illuminate/config": "^10.0", - "illuminate/console": "^10.0", - "illuminate/container": "^10.0", - "illuminate/database": "^10.0", - "illuminate/http": "^10.0", - "illuminate/support": "^10.0" + "illuminate/cache": "^10.0|^11.0", + "illuminate/config": "^10.0|^11.0", + "illuminate/console": "^10.0|^11.0", + "illuminate/container": "^10.0|^11.0", + "illuminate/database": "^10.0|^11.0", + "illuminate/http": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0" }, "require-dev": { "doctrine/dbal": "^3.3", "fakerphp/faker": "^1.11", "laravel/nova": "^4.0", "orchestra/testbench-browser-kit": "^8.0", - "orchestra/testbench": "^8.0", - "php-coveralls/php-coveralls" : "^2.2", + "orchestra/testbench": "^8.0|^9.0", + "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^10.0", - "slevomat/coding-standard": "^7.0", + "slevomat/coding-standard": "^7.0|^8.14", "squizlabs/php_codesniffer": "^3.6", "symfony/thanks": "^1.2", "laravel/legacy-factories": "^1.3" From 38adb0ab25091b8d1dc05fb78bdc6bbcb71ad9ad Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 21:44:51 +0000 Subject: [PATCH 12/43] Brought tests to green. --- .github/workflows/laravel.yml | 2 +- src/Traits/Caching.php | 9 ++++--- tests/CreatesApplication.php | 16 ++++++++--- tests/Feature/PaginationTest.php | 24 ++++++++++++++--- .../CachedBuilder/PaginateTest.php | 27 ++++++++++++++++--- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 35899136..1ed4c2c3 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2, 8.1] + php: [8.3, 8.2, 8.1] name: PHP ${{ matrix.php }} diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php index 7762a593..f85a54b3 100644 --- a/src/Traits/Caching.php +++ b/src/Traits/Caching.php @@ -41,7 +41,7 @@ public function applyScopes() if ($this->scopesAreApplied) { return $this; } - + return parent::applyScopes(); } @@ -170,7 +170,7 @@ protected function makeCacheKey( ?? Container::getInstance() ->make("db") ->query(); - + if ( $this->query && method_exists($this->query, "getQuery") @@ -263,7 +263,7 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance) protected function checkCooldownAndFlushAfterPersisting(Model $instance, string $relationship = "") { - if (!$this->isCachable()) { + if (! $this->isCachable()) { return; } @@ -299,6 +299,7 @@ public function isCachable() : bool $isCacheDisabled = ! Container::getInstance() ->make("config") ->get("laravel-model-caching.enabled"); + if ($isCacheDisabled) { return false; } @@ -319,7 +320,7 @@ public function isCachable() : bool ) { return $carry; } - + $relatedModel = $this->model->$related()->getRelated(); if ( diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index b402ab3a..7b70d647 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -139,18 +139,26 @@ protected function getEnvironmentSetUp($app) ]); } - public function appVersionEightAndUp(): bool + public function appVersionEightAndNine(): bool { - return version_compare(app()->version(), '8.0.0', '>='); + return version_compare(app()->version(), '8.0.0', '>=') + && version_compare(app()->version(), '10.0.0', '<'); } public function appVersionFiveBetweenSeven(): bool { - return version_compare(app()->version(), '5.6.0', '>=') && version_compare(app()->version(), '8.0.0', '<'); + return version_compare(app()->version(), '5.6.0', '>=') + && version_compare(app()->version(), '8.0.0', '<'); } public function appVersionOld(): bool { - return version_compare(app()->version(), '5.4.0', '>=') && version_compare(app()->version(), '5.6.0', '<'); + return version_compare(app()->version(), '5.4.0', '>=') + && version_compare(app()->version(), '5.6.0', '<'); + } + + public function appVersionTen(): bool + { + return version_compare(app()->version(), '10.0.0', '>='); } } diff --git a/tests/Feature/PaginationTest.php b/tests/Feature/PaginationTest.php index 465ec823..ab8e751c 100644 --- a/tests/Feature/PaginationTest.php +++ b/tests/Feature/PaginationTest.php @@ -7,8 +7,14 @@ class PaginationTest extends FeatureTestCase { public function testPaginationProvidesDifferentLinksOnDifferentPages() { + // Checking the version start with 10.0. + if ($this->appVersionTen()) { + $page1ActiveLink = '1'; + $page2ActiveLink = '2'; + } + // Checking the version start with 8.0. - if ($this->appVersionEightAndUp()) { + if ($this->appVersionEightAndNine()) { $page1ActiveLink = '1'; $page2ActiveLink = '2'; } @@ -39,8 +45,14 @@ public function testPaginationProvidesDifferentLinksOnDifferentPages() public function testAdvancedPagination() { + // Checking the version start with 10.0. + if ($this->appVersionTen()) { + $page1ActiveLink = '1'; + $page2ActiveLink = '2'; + } + // Checking the version start with 8.0. - if ($this->appVersionEightAndUp()) { + if ($this->appVersionEightAndNine()) { $page1ActiveLink = '1'; $page2ActiveLink = '2'; } @@ -62,8 +74,14 @@ public function testAdvancedPagination() public function testCustomPagination() { + // Checking the version start with 10.0. + if ($this->appVersionTen()) { + $page1ActiveLink = '1'; + $page2ActiveLink = '2'; + } + // Checking the version start with 8.0. - if ($this->appVersionEightAndUp()) { + if ($this->appVersionEightAndNine()) { $page1ActiveLink = '1'; $page2ActiveLink = '2'; } diff --git a/tests/Integration/CachedBuilder/PaginateTest.php b/tests/Integration/CachedBuilder/PaginateTest.php index 0ac4ead0..5d95b3d3 100644 --- a/tests/Integration/CachedBuilder/PaginateTest.php +++ b/tests/Integration/CachedBuilder/PaginateTest.php @@ -36,7 +36,14 @@ public function testPaginationIsCached() public function testPaginationReturnsCorrectLinks() { - if ($this->appVersionEightAndUp()) { + // Checking the version start with 10.0. + if ($this->appVersionTen()) { + $page1ActiveLink = '1'; + $page2ActiveLink = '2'; + $page24ActiveLink = '24'; + } + + if ($this->appVersionEightAndNine()) { $page1ActiveLink = '1'; $page2ActiveLink = '2'; $page24ActiveLink = '24'; @@ -71,7 +78,14 @@ public function testPaginationReturnsCorrectLinks() public function testPaginationWithOptionsReturnsCorrectLinks() { - if ($this->appVersionEightAndUp()) { + // Checking the version start with 10.0. + if ($this->appVersionTen()) { + $page1ActiveLink = '1'; + $page2ActiveLink = '2'; + $page24ActiveLink = '24'; + } + + if ($this->appVersionEightAndNine()) { $page1ActiveLink = '1'; $page2ActiveLink = '2'; $page24ActiveLink = '24'; @@ -106,7 +120,14 @@ public function testPaginationWithOptionsReturnsCorrectLinks() public function testPaginationWithCustomOptionsReturnsCorrectLinks() { - if ($this->appVersionEightAndUp()) { + // Checking the version start with 10.0. + if ($this->appVersionTen()) { + $page1ActiveLink = '1'; + $page2ActiveLink = '2'; + $page24ActiveLink = '24'; + } + + if ($this->appVersionEightAndNine()) { $page1ActiveLink = '1'; $page2ActiveLink = '2'; $page24ActiveLink = '24'; From da53fcc9e71e8729de5cf8fcaaf093a3dc14935d Mon Sep 17 00:00:00 2001 From: Kieran Date: Sat, 2 Mar 2024 21:46:09 +0000 Subject: [PATCH 13/43] Ensure isCacheable in checkCooldownAndFlushAfterPersisting (#458) --- src/Traits/Caching.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php index 5d5fccb9..7762a593 100644 --- a/src/Traits/Caching.php +++ b/src/Traits/Caching.php @@ -263,6 +263,10 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance) protected function checkCooldownAndFlushAfterPersisting(Model $instance, string $relationship = "") { + if (!$this->isCachable()) { + return; + } + [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance); if (! $cacheCooldown) { @@ -295,6 +299,10 @@ public function isCachable() : bool $isCacheDisabled = ! Container::getInstance() ->make("config") ->get("laravel-model-caching.enabled"); + if ($isCacheDisabled) { + return false; + } + $allRelationshipsAreCachable = true; if ( @@ -327,7 +335,6 @@ public function isCachable() : bool } return $this->isCachable - && ! $isCacheDisabled && $allRelationshipsAreCachable; } From b3764ca06e1e6e8d5815785f69bce13b6da47a95 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 21:49:28 +0000 Subject: [PATCH 14/43] WIP --- src/Traits/Caching.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php index b882948c..f85a54b3 100644 --- a/src/Traits/Caching.php +++ b/src/Traits/Caching.php @@ -299,7 +299,7 @@ public function isCachable() : bool $isCacheDisabled = ! Container::getInstance() ->make("config") ->get("laravel-model-caching.enabled"); -a + if ($isCacheDisabled) { return false; } From 50d76061ff91a0f87f5eb532cc3cab46fae653e1 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:09:00 +0000 Subject: [PATCH 15/43] WIP --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 1ed4c2c3..1ce1d96a 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -56,7 +56,7 @@ jobs: - name: Install Dependencies run: | - composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_PASSWORD }}" + composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_LICENSE_KEY }}" composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist - name: Execute Integration and Feature tests via PHPUnit From 49bcc5adb41ab6bea7b75690a805510b64e7a705 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:11:26 +0000 Subject: [PATCH 16/43] WIP --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 1ce1d96a..dac061b9 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.3, 8.2, 8.1] + php: [8.2, 8.1] name: PHP ${{ matrix.php }} From 5933b33b62b97b78e772d7689678d9f324e90fa9 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:13:16 +0000 Subject: [PATCH 17/43] WIP --- .github/workflows/laravel.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index dac061b9..50f69e03 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -60,8 +60,8 @@ jobs: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist - name: Execute Integration and Feature tests via PHPUnit - run: vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite Integration,Feature + run: vendor/bin/phpunit --configuration phpunit.xml --testsuite Integration,Feature - name: Execute Nova tests via PHPUnit if: github.event_name != 'pull_request' - run: vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite Nova + run: vendor/bin/phpunit --configuration phpunit.xml --testsuite Nova From 8deb25022b1dd50b1eb05f7fb313804aee46060b Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:15:36 +0000 Subject: [PATCH 18/43] WIP --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 50f69e03..645d621d 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2, 8.1] + php: [8.2] name: PHP ${{ matrix.php }} From 168c525d7d75a128f728b47c6ddf17bc66d9661b Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:19:28 +0000 Subject: [PATCH 19/43] WIP --- .github/workflows/laravel.yml | 6 ++--- phpunit.xml.dist | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 phpunit.xml.dist diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 645d621d..dac061b9 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2] + php: [8.2, 8.1] name: PHP ${{ matrix.php }} @@ -60,8 +60,8 @@ jobs: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist - name: Execute Integration and Feature tests via PHPUnit - run: vendor/bin/phpunit --configuration phpunit.xml --testsuite Integration,Feature + run: vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite Integration,Feature - name: Execute Nova tests via PHPUnit if: github.event_name != 'pull_request' - run: vendor/bin/phpunit --configuration phpunit.xml --testsuite Nova + run: vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite Nova diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..3c8ff2dd --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,41 @@ + + + + + ./tests/Feature + + + ./tests/Integration + + + ./tests/Nova + + + + + ./src + + + + + + + + + + + + + + + From 546397c3c4431f956fc84736b01dd06f592b4ca2 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:28:40 +0000 Subject: [PATCH 20/43] WIP --- phpunit.xml.dist | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3c8ff2dd..c74eae32 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,14 @@ @@ -21,11 +21,6 @@ ./tests/Nova - - - ./src - - @@ -38,4 +33,9 @@ + + + ./src + + From a6722e527e6b227e9c75932576385a4a1fe3a033 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:31:49 +0000 Subject: [PATCH 21/43] WIP --- phpunit.xml.dist | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c74eae32..6ccffab5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,16 +22,18 @@ - + - - - + + + + + From 4499d4e39a7b673ce081c3bf7a72d34ec095f296 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:33:53 +0000 Subject: [PATCH 22/43] WIP --- phpunit.xml.dist | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6ccffab5..1a75ca56 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,18 +22,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + From eda274d2fcdc45da6a90363ab8b035bd1a2635e2 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:36:21 +0000 Subject: [PATCH 23/43] WIP --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index dac061b9..b2d1c370 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -44,7 +44,7 @@ jobs: with: postgresql version: '15' postgresql db: 'testing' - postgresql user: 'homestead' + postgresql user: 'forge' postgresql password: 'secret' - name: Remove Nova on a pull request From a0c1468412ba715447882f0d0e739329537a5c76 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Sat, 2 Mar 2024 22:45:21 +0000 Subject: [PATCH 24/43] WIP --- .github/workflows/laravel.yml | 2 +- phpunit.xml.dist | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index b2d1c370..c32d3fc6 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2, 8.1] + php: [8.3, 8.2] name: PHP ${{ matrix.php }} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1a75ca56..45a3ad26 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -28,8 +28,6 @@ - - From 487a84eb9759bf9e5fabc3d64c200dc2ee952699 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Sat, 2 Mar 2024 17:46:23 -0500 Subject: [PATCH 25/43] Bump dependencies for Laravel 11 (#459) --- composer.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 68e81339..dd32aafe 100644 --- a/composer.json +++ b/composer.json @@ -17,23 +17,23 @@ "require": { "php": ">=8.1", "genealabs/laravel-pivot-events": "^10.0", - "illuminate/cache": "^10.0", - "illuminate/config": "^10.0", - "illuminate/console": "^10.0", - "illuminate/container": "^10.0", - "illuminate/database": "^10.0", - "illuminate/http": "^10.0", - "illuminate/support": "^10.0" + "illuminate/cache": "^10.0|^11.0", + "illuminate/config": "^10.0|^11.0", + "illuminate/console": "^10.0|^11.0", + "illuminate/container": "^10.0|^11.0", + "illuminate/database": "^10.0|^11.0", + "illuminate/http": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0" }, "require-dev": { "doctrine/dbal": "^3.3", "fakerphp/faker": "^1.11", "laravel/nova": "^4.0", "orchestra/testbench-browser-kit": "^8.0", - "orchestra/testbench": "^8.0", - "php-coveralls/php-coveralls" : "^2.2", + "orchestra/testbench": "^8.0|^9.0", + "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^10.0", - "slevomat/coding-standard": "^7.0", + "slevomat/coding-standard": "^7.0|^8.14", "squizlabs/php_codesniffer": "^3.6", "symfony/thanks": "^1.2", "laravel/legacy-factories": "^1.3" From 2a38f0f1ed3554cf2da272d66c4d08a7885f196b Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Thu, 14 Mar 2024 16:34:57 -0700 Subject: [PATCH 26/43] Update composer.json Signed-off-by: Mike Bronner --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index dd32aafe..a3570e3d 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": ">=8.1", - "genealabs/laravel-pivot-events": "^10.0", + "genealabs/laravel-pivot-events": "^10.0|^11.0", "illuminate/cache": "^10.0|^11.0", "illuminate/config": "^10.0|^11.0", "illuminate/console": "^10.0|^11.0", From a38c905790c73c43dac09790eec7f0972cd651cc Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Fri, 15 Mar 2024 12:40:22 +0000 Subject: [PATCH 27/43] WIP --- .vscode/settings.json | 4 ++-- composer.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 66f1adce..e614d03c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -128,7 +128,7 @@ "editor.inlayHints.fontFamily": "JetBrains Mono", "editor.inlineSuggest.enabled": true, "editor.insertSpaces": true, - "editor.lightbulb.enabled": false, + "editor.lightbulb.enabled": "off", "editor.linkedEditing": true, "editor.minimap.maxColumn": 100, "editor.parameterHints.enabled": false, @@ -313,6 +313,6 @@ "[php]": { "editor.defaultFormatter": "bmewburn.vscode-intelephense-client" }, - "window.title": "totality", + "window.title": "laravel-model-caching", "workbench.editor.tabActionLocation": "left" } diff --git a/composer.json b/composer.json index a3570e3d..3d7c3d8e 100644 --- a/composer.json +++ b/composer.json @@ -29,10 +29,10 @@ "doctrine/dbal": "^3.3", "fakerphp/faker": "^1.11", "laravel/nova": "^4.0", - "orchestra/testbench-browser-kit": "^8.0", - "orchestra/testbench": "^8.0|^9.0", + "orchestra/testbench-browser-kit": "^9.0", + "orchestra/testbench": "^9.0", "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.5", "slevomat/coding-standard": "^7.0|^8.14", "squizlabs/php_codesniffer": "^3.6", "symfony/thanks": "^1.2", From 431b4caa224ed3258a6d7efb88d5be8c5e4c4e0d Mon Sep 17 00:00:00 2001 From: Josh Ralph Date: Mon, 24 Feb 2025 18:08:27 +0000 Subject: [PATCH 28/43] Code style clean up --- src/CacheKey.php | 2 +- src/Traits/Buildable.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CacheKey.php b/src/CacheKey.php index 49ca3785..2a514429 100644 --- a/src/CacheKey.php +++ b/src/CacheKey.php @@ -246,7 +246,7 @@ protected function getOtherClauses(array $where) : string $column = ""; - if (data_get($where, "column") instanceof Expression) { + if (data_get($where, "column") instanceof Expression) { $where["column"] = $this->expressionToString(data_get($where, "column")); } diff --git a/src/Traits/Buildable.php b/src/Traits/Buildable.php index 0fcf5bde..34af7002 100644 --- a/src/Traits/Buildable.php +++ b/src/Traits/Buildable.php @@ -176,7 +176,7 @@ public function paginate( if (is_array($page)) { $page = $this->recursiveImplodeWithKey($page); } - + $columns = collect($columns)->toArray(); $keyDifferentiator = "-paginate_by_{$perPage}_{$pageName}_{$page}"; @@ -325,12 +325,12 @@ function () use ($arguments, $cacheKey, $method) { * The risk of this change is if any application code is dependent on the `pivotParent` property * of a cached Pivot record, then you're a bit out of luck and would need to have a fallback. */ - if (is_iterable($value) && !empty($value)) { - foreach ($value as $index => $model) { - if (!empty($model) && is_object($model) && $model?->pivot?->pivotParent) { + if (is_iterable($value) && ! empty($value)) { + foreach ($value as $model) { + if (! empty($model) && is_object($model) && $model?->pivot?->pivotParent) { unset($model->pivot->pivotParent); - } - } + } + } } return [ "key" => $cacheKey, From f209bc3cfc8f0b3722de3f5ebe59bdaad04575f2 Mon Sep 17 00:00:00 2001 From: domhaas Date: Wed, 26 Feb 2025 23:59:48 +0100 Subject: [PATCH 29/43] Update README.md (#474) added "laravel-adjacency-list" to conflicting-list Signed-off-by: domhaas --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 86d86357..2973936b 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ The following are packages we have identified as conflicting: - [spatie/laravel-query-builder](https://github.com/spatie/laravel-query-builder) - [dwightwatson/rememberable](https://github.com/dwightwatson/rememberable) - [kalnoy/nestedset](https://github.com/lazychaser/laravel-nestedset) +- [laravel-adjacency-list](https://github.com/staudenmeir/laravel-adjacency-list) ### Things That Don't Work Currently The following items currently do no work with this package: From 44b077236968a9acbc3e16683516ec8db7a8f504 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 27 Feb 2025 00:00:35 +0100 Subject: [PATCH 30/43] Fix cachekey issue (#471) This should fix #470 by making sure all columns are strings before imploding them. Signed-off-by: James Cole --- src/CacheKey.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CacheKey.php b/src/CacheKey.php index 057582f0..eea4e290 100644 --- a/src/CacheKey.php +++ b/src/CacheKey.php @@ -263,6 +263,10 @@ protected function getQueryColumns(array $columns) : string return "_" . implode("_", $columns); } + $columns = array_map(function ($column) { + return $this->expressionToString($column); + }, $columns); + return "_" . implode("_", $columns); } From b28e0308c7d8f8b895ba6195c910f1645b351396 Mon Sep 17 00:00:00 2001 From: Dan-Radu Pana Date: Thu, 27 Feb 2025 01:01:04 +0200 Subject: [PATCH 31/43] [Fix] Carbon v3 new method default parameter compatibility (#469) --- src/Traits/Caching.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php index f85a54b3..97480821 100644 --- a/src/Traits/Caching.php +++ b/src/Traits/Caching.php @@ -241,7 +241,7 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance) if ( ! $cacheCooldown - || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown + || (new Carbon)->now()->diffInSeconds($invalidatedAt, true) < $cacheCooldown ) { return; } @@ -285,7 +285,7 @@ protected function checkCooldownAndFlushAfterPersisting(Model $instance, string $this->setCacheCooldownSavedAtTimestamp($instance); - if ((new Carbon)->now()->diffInSeconds($invalidatedAt) >= $cacheCooldown) { + if ((new Carbon)->now()->diffInSeconds($invalidatedAt, true) >= $cacheCooldown) { $instance->flushCache(); if ($relationship) { From 4490d5aaee8c9a09106808c53471d923fd0f88ef Mon Sep 17 00:00:00 2001 From: Ruben Robles Date: Thu, 27 Feb 2025 00:01:28 +0100 Subject: [PATCH 32/43] fix deprecations with nullable func args in php 8.4 (#477) --- src/Traits/BuilderCaching.php | 2 +- src/Traits/ModelCaching.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Traits/BuilderCaching.php b/src/Traits/BuilderCaching.php index e3cc90f0..f51d247d 100644 --- a/src/Traits/BuilderCaching.php +++ b/src/Traits/BuilderCaching.php @@ -31,7 +31,7 @@ public function withoutGlobalScope($scope) return parent::withoutGlobalScope($scope); } - public function withoutGlobalScopes(array $scopes = null) + public function withoutGlobalScopes(?array $scopes = null) { if ($scopes !== null) { $this->withoutGlobalScopes = $scopes; diff --git a/src/Traits/ModelCaching.php b/src/Traits/ModelCaching.php index 1f428c36..539b9b3b 100644 --- a/src/Traits/ModelCaching.php +++ b/src/Traits/ModelCaching.php @@ -160,7 +160,7 @@ public function scopeDisableCache(EloquentBuilder $query) : EloquentBuilder public function scopeWithCacheCooldownSeconds( EloquentBuilder $query, - int $seconds = null + ?int $seconds = null ) : EloquentBuilder { if (! $seconds) { $seconds = $this->cacheCooldownSeconds; From 5c67470cef4b9ecab7bdbb40fefffbf981f1c438 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Wed, 26 Feb 2025 18:01:56 -0500 Subject: [PATCH 33/43] Bump dependencies for Laravel 12 (#478) --- composer.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 3d7c3d8e..67c9334e 100644 --- a/composer.json +++ b/composer.json @@ -17,22 +17,22 @@ "require": { "php": ">=8.1", "genealabs/laravel-pivot-events": "^10.0|^11.0", - "illuminate/cache": "^10.0|^11.0", - "illuminate/config": "^10.0|^11.0", - "illuminate/console": "^10.0|^11.0", - "illuminate/container": "^10.0|^11.0", - "illuminate/database": "^10.0|^11.0", - "illuminate/http": "^10.0|^11.0", - "illuminate/support": "^10.0|^11.0" + "illuminate/cache": "^10.0|^11.0|^12.0", + "illuminate/config": "^10.0|^11.0|^12.0", + "illuminate/console": "^10.0|^11.0|^12.0", + "illuminate/container": "^10.0|^11.0|^12.0", + "illuminate/database": "^10.0|^11.0|^12.0", + "illuminate/http": "^10.0|^11.0|^12.0", + "illuminate/support": "^10.0|^11.0|^12.0" }, "require-dev": { - "doctrine/dbal": "^3.3", + "doctrine/dbal": "^3.3|^4.2", "fakerphp/faker": "^1.11", "laravel/nova": "^4.0", - "orchestra/testbench-browser-kit": "^9.0", - "orchestra/testbench": "^9.0", + "orchestra/testbench-browser-kit": "^9.0|^10.0", + "orchestra/testbench": "^9.0|^10.0", "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^10.5", + "phpunit/phpunit": "^10.5|^11.5.3", "slevomat/coding-standard": "^7.0|^8.14", "squizlabs/php_codesniffer": "^3.6", "symfony/thanks": "^1.2", From 83b26190ad2836bf61dcb570978e24e6f1e43f7f Mon Sep 17 00:00:00 2001 From: Dan-Radu Pana Date: Thu, 27 Feb 2025 01:03:44 +0200 Subject: [PATCH 34/43] Fixes `query` attribute not existing under strict mode (#465) * Fixes `query` attribute not existing under strict mode * Update ModelCaching.php Signed-off-by: Mike Bronner --------- Signed-off-by: Mike Bronner Co-authored-by: Mike Bronner --- src/Traits/ModelCaching.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Traits/ModelCaching.php b/src/Traits/ModelCaching.php index 539b9b3b..b18927d7 100644 --- a/src/Traits/ModelCaching.php +++ b/src/Traits/ModelCaching.php @@ -22,6 +22,11 @@ public function __get($key) ?? 0; } + if ($key === "query") { + return $this->query + ?? $this->newModelQuery(); + } + return parent::__get($key); } From 1f3cf3fbd4e740cd839652617bef1b4b893a518a Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 16:04:11 -0700 Subject: [PATCH 35/43] WIP --- phpunit.xml | 8 ++++---- tests/Integration/CachedModelTest.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index eeb38981..c26ddd53 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -31,10 +31,10 @@ - - - - + + + + diff --git a/tests/Integration/CachedModelTest.php b/tests/Integration/CachedModelTest.php index af6e2524..dc932645 100644 --- a/tests/Integration/CachedModelTest.php +++ b/tests/Integration/CachedModelTest.php @@ -1,11 +1,11 @@ withCacheCooldownSeconds(1) ->first(); - + [$usesCacheCooldown, $expiresAt, $savedAt] = $method->invokeArgs($author, [$author]); $this->assertEquals($usesCacheCooldown, 1); @@ -188,7 +188,7 @@ public function testModelCacheDoesntInvalidateDuringCooldownPeriod() ->get(); $uncachedAuthors = (new UncachedAuthor) ->get(); - sleep(2); + sleep(3); $authorsAfterCooldown = (new AuthorWithCooldown) ->get(); From 6bb6a5676fb2bc6d277fe7abf5f82839bb457c3f Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 16:05:53 -0700 Subject: [PATCH 36/43] Added php 8.4 tests. --- .github/workflows/laravel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index c32d3fc6..f5bcd953 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.3, 8.2] + php: [8.4, 8.3, 8.2] name: PHP ${{ matrix.php }} From b134e526a5a84aa78318a8d61d957de5992976e5 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 16:07:02 -0700 Subject: [PATCH 37/43] Updated namespace. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 67c9334e..85232039 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "genealabs/laravel-model-caching", + "name": "mikebronner/laravel-model-caching", "description": "Automatic caching for Eloquent models.", "license": "MIT", "authors": [ From 13a21d754938e5ba9e39b618448b0dcf5ab6c2bf Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 16:16:16 -0700 Subject: [PATCH 38/43] Update README.md Signed-off-by: Mike Bronner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2973936b..f8c04ce7 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The following items currently do no work with this package: ## Installation Be sure to not require a specific version of this package when requiring it: ``` -composer require genealabs/laravel-model-caching +composer require mikebronner/laravel-model-caching ``` ### Gotchas If Using With Lumen From b4fbabd0eb66774b9fb7d0574804fb7d8e643372 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 16:55:11 -0700 Subject: [PATCH 39/43] Fixed package dependency. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 85232039..de5669c6 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": ">=8.1", - "genealabs/laravel-pivot-events": "^10.0|^11.0", + "mikebronner/laravel-pivot-events": "^10.0|^11.0|^12.0", "illuminate/cache": "^10.0|^11.0|^12.0", "illuminate/config": "^10.0|^11.0|^12.0", "illuminate/console": "^10.0|^11.0|^12.0", @@ -28,7 +28,7 @@ "require-dev": { "doctrine/dbal": "^3.3|^4.2", "fakerphp/faker": "^1.11", - "laravel/nova": "^4.0", + "laravel/nova": "^5.0", "orchestra/testbench-browser-kit": "^9.0|^10.0", "orchestra/testbench": "^9.0|^10.0", "php-coveralls/php-coveralls": "^2.2", From 90901c7edd2934304d1d6c55bf8cce132c90fa5d Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 17:34:22 -0700 Subject: [PATCH 40/43] Fixed #480 --- tests/NovaTestCase.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/NovaTestCase.php b/tests/NovaTestCase.php index 9a25ec4b..d1885ade 100644 --- a/tests/NovaTestCase.php +++ b/tests/NovaTestCase.php @@ -1,5 +1,7 @@ authenticate(); + $this->withoutMiddleware(); + + Artisan::call("nova:publish"); } protected function authenticate() @@ -54,6 +61,7 @@ protected function getPackageProviders($app) NovaCoreServiceProvider::class, \Laravel\Nova\NovaServiceProvider::class, NovaServiceProvider::class, + ServiceProvider::class, ] ); } From 4c8dfda24617462bdd9317d1ea5ce40790b6b77d Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 17:37:28 -0700 Subject: [PATCH 41/43] Create FUNDING.yml Signed-off-by: Mike Bronner --- .github/FUNDING.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..58c2ca39 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: [mikebronner] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 03ac02635ffb75ad957ad17454272f48f1a4887f Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Wed, 26 Feb 2025 17:39:38 -0700 Subject: [PATCH 42/43] Delete .github/FUNDING.yml Signed-off-by: Mike Bronner --- .github/FUNDING.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 58c2ca39..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,15 +0,0 @@ -# These are supported funding model platforms - -github: [mikebronner] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -polar: # Replace with a single Polar username -buy_me_a_coffee: # Replace with a single Buy Me a Coffee username -thanks_dev: # Replace with a single thanks.dev username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 5d4c73eea09c08cca29c1c2ed3a22301cd04a2ce Mon Sep 17 00:00:00 2001 From: Josh Ralph Date: Thu, 13 Mar 2025 11:46:35 +0000 Subject: [PATCH 43/43] Restored previous behaviour where running in a runDisabled callback still flushes model caches --- src/Traits/Caching.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Traits/Caching.php b/src/Traits/Caching.php index 97480821..fcf85247 100644 --- a/src/Traits/Caching.php +++ b/src/Traits/Caching.php @@ -263,9 +263,14 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance) protected function checkCooldownAndFlushAfterPersisting(Model $instance, string $relationship = "") { - if (! $this->isCachable()) { - return; - } + /** + * Our usage of the library currently expects model caches to be flushed in the usual way, even + * whilst code is run in a `runDisabled` callback. Leaving this check in place introduced all + * sorts of issues where caches weren't being flushed where they needed to be. + */ + // if (! $this->isCachable()) { + // return; + // } [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance);