diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..eaac2e1e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,101 @@ +// 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", + "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": [ + 5432, + 6379 + ], + "portsAttributes": { + "5432": { + "label": "Postgres" + }, + "6379": { + "label": "Redis" + } + }, + "mounts": [ + "source=${localEnv:HOME}/.wakatime.cfg,target=/home/sail/.wakatime.cfg,type=bind,consistency=delegated" + ] + // "runServices": [], + // "shutdownAction": "none", +} 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 43663e4f..f5bcd953 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -14,12 +14,13 @@ jobs: strategy: fail-fast: true matrix: - php: [7.3, 7.4, 8.0] + php: [8.4, 8.3, 8.2] name: PHP ${{ matrix.php }} steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v3 - name: Cache dependencies uses: actions/cache@v1 @@ -41,9 +42,9 @@ jobs: - uses: harmon758/postgresql-action@v1 with: - postgresql version: '11' + postgresql version: '15' postgresql db: 'testing' - postgresql user: 'homestead' + postgresql user: 'forge' postgresql password: 'secret' - name: Remove Nova on a pull request @@ -55,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 diff --git a/.gitignore b/.gitignore index 48b61660..8fbb4834 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ +.idea +.phpunit.result.cache +/.phpunit* /build /vendor composer.lock -.phpunit.result.cache -phpunit.xml diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..757b5a7d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,69 @@ +{ + "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", + "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" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..e614d03c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,318 @@ +{ + "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": "off", + "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": "off", + "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": false, + "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, + "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": "single", + "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": "laravel-model-caching", + "workbench.editor.tabActionLocation": "left" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index d1d41633..7a4092cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.12.5] - 2022-07-30 +### Added +- pivotSynced event listener to flush cache when performing BelongsToMany::sync + +[...] + ## [0.10.3] - 2021-03-16 ### Changed - The from part of the query ($query->from) instead of the table name of the model ($model->table) diff --git a/README.md b/README.md index abc66d0f..a1562356 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ ## Supporting This Package This is an MIT-licensed open source project with its ongoing development made possible by the support of the community. If you'd like to support this, and our other packages, please consider [becoming a sponsor](https://github.com/sponsors/mikebronner). +We thank the following sponsors for their generosity, please take a moment to check them out: + +- [LIX](https://lix-it.com) + ## Impetus I created this package in response to a client project that had complex, nested forms with many `