From 829e1debbfc1c33572336a9d757e94dd305488f8 Mon Sep 17 00:00:00 2001 From: Jeremy Layson Date: Wed, 3 Apr 2024 15:05:39 +0800 Subject: [PATCH 1/6] Tested Version --- composer.json | 3 +- composer.lock | 916 +++++++++++++----- .../Resources/AbstractContentResource.php | 4 +- src/Models/AbstractContentModel.php | 11 + 4 files changed, 714 insertions(+), 220 deletions(-) diff --git a/composer.json b/composer.json index 477d946a..c2a1e7d9 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "awcodes/filament-tiptap-editor": "^3.0", "mistralys/text-diff": "^2.0", "spatie/laravel-permission": "^6.3", - "laravel/framework": "^10.0" + "laravel/framework": "^10.0", + "ralphjsmit/laravel-filament-seo": "^1.3" }, "require-dev": { "laravel/sanctum": "^3.3", diff --git a/composer.lock b/composer.lock index 74b01949..98a72573 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fb24406bba4892a50a80cd73e8947de9", + "content-hash": "56cfa7f5644501e9357d7f7c9978c15f", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -1859,6 +1859,331 @@ ], "time": "2023-11-12T22:16:48+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "7.8.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104", + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.1", + "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.36 || ^9.6.15", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.8.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2023-12-03T20:35:24+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223", + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.36 || ^9.6.15" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2023-12-03T20:19:20+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.6.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.36 || ^9.6.15" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.6.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2023-12-03T20:05:35+00:00" + }, { "name": "guzzlehttp/uri-template", "version": "v1.0.3", @@ -4215,6 +4540,58 @@ }, "time": "2019-01-08T18:20:26+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, { "name": "psr/http-factory", "version": "1.0.2", @@ -4284,18 +4661,233 @@ "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", "shasum": "" }, - "require": { - "php": "^7.2 || ^8.0" + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "ralphjsmit/laravel-filament-seo", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/ralphjsmit/laravel-filament-seo.git", + "reference": "e9f1531187e8692609a74dfafe2cabc9ef6827f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralphjsmit/laravel-filament-seo/zipball/e9f1531187e8692609a74dfafe2cabc9ef6827f6", + "reference": "e9f1531187e8692609a74dfafe2cabc9ef6827f6", + "shasum": "" + }, + "require": { + "filament/filament": "^3.0", + "illuminate/contracts": "^9.52|^10.0|^11.0", + "php": "^8.0", + "ralphjsmit/laravel-seo": "^1.0.4", + "spatie/laravel-package-tools": "^1.9.2" + }, + "require-dev": { + "doctrine/dbal": "^3.8", + "nesbot/carbon": "^2.66|^3.0", + "nunomaduro/collision": "^6.1|^7.0|^8.0", + "orchestra/testbench": "^7.0|^8.0|^9.0", + "pestphp/pest": "^1.21|^2.0", + "pestphp/pest-plugin-laravel": "^1.1|^2.0", + "phpunit/phpunit": "^9.5|^10.5", + "spatie/laravel-ray": "^1.26" }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" + "laravel": { + "providers": [ + "RalphJSmit\\Filament\\SEO\\FilamentSEOServiceProvider" + ], + "aliases": [] } }, "autoload": { "psr-4": { - "Psr\\Http\\Message\\": "src/" + "RalphJSmit\\Filament\\SEO\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -4304,51 +4896,74 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Ralph J. Smit", + "email": "rjs@ralphjsmit.com", + "role": "Developer" } ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", + "description": "A package to combine the power of Laravel SEO and Filament Admin.", + "homepage": "https://github.com/ralphjsmit/laravel-filament-seo", "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" + "laravel", + "laravel-filament-seo", + "ralphjsmit" ], "support": { - "source": "https://github.com/php-fig/http-message/tree/2.0" + "issues": "https://github.com/ralphjsmit/laravel-filament-seo/issues", + "source": "https://github.com/ralphjsmit/laravel-filament-seo/tree/1.3.0" }, - "time": "2023-04-04T09:54:51+00:00" + "time": "2024-03-14T09:47:06+00:00" }, { - "name": "psr/log", - "version": "3.0.0", + "name": "ralphjsmit/laravel-helpers", + "version": "1.9.0", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + "url": "https://github.com/ralphjsmit/laravel-helpers.git", + "reference": "840b4979a92c7b676d25f56430823f12481f2914" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", - "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "url": "https://api.github.com/repos/ralphjsmit/laravel-helpers/zipball/840b4979a92c7b676d25f56430823f12481f2914", + "reference": "840b4979a92c7b676d25f56430823f12481f2914", "shasum": "" }, "require": { - "php": ">=8.0.0" + "guzzlehttp/guzzle": "^7.4", + "illuminate/contracts": "^8.73|^9.0|^10.0|^11.0", + "php": "^8.0", + "spatie/laravel-package-tools": "^1.9.2" + }, + "require-dev": { + "livewire/livewire": "^2.9|^3.4", + "nesbot/carbon": "^2.66|^3.0", + "nunomaduro/collision": "^5.10|^6.1|^7.0|^8.0", + "orchestra/testbench": "^6.22|^7.0|^8.0|^9.0", + "pestphp/pest": "^1.21|^2.34", + "pestphp/pest-plugin-laravel": "^1.1|^2.3", + "phpunit/phpunit": "^9.5|^10.5", + "spatie/invade": "^1.0|^2.0", + "spatie/laravel-ray": "^1.26" }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "3.x-dev" + "laravel": { + "providers": [ + "RalphJSmit\\Helpers\\HelpersServiceProvider" + ], + "aliases": { + "Helpers": "RalphJSmit\\Helpers\\Facades\\Helpers" + } } }, "autoload": { + "files": [ + "src/Laravel/Support/helpers.php", + "src/helpers.php" + ], "psr-4": { - "Psr\\Log\\": "src" + "RalphJSmit\\Helpers\\": "src", + "RalphJSmit\\Helpers\\Database\\Factories\\": "database/factories" } }, "notification-url": "https://packagist.org/downloads/", @@ -4357,48 +4972,72 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Ralph J. Smit", + "email": "rjs@ralphjsmit.com", + "role": "Developer" } ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", + "description": "A package containing handy helpers for your Laravel-application.", + "homepage": "https://github.com/ralphjsmit/laravel-helpers", "keywords": [ - "log", - "psr", - "psr-3" + "laravel", + "laravel-helpers", + "ralphjsmit" ], "support": { - "source": "https://github.com/php-fig/log/tree/3.0.0" + "issues": "https://github.com/ralphjsmit/laravel-helpers/issues", + "source": "https://github.com/ralphjsmit/laravel-helpers/tree/1.9.0" }, - "time": "2021-07-14T16:46:02+00:00" + "time": "2024-03-14T08:30:30+00:00" }, { - "name": "psr/simple-cache", - "version": "3.0.0", + "name": "ralphjsmit/laravel-seo", + "version": "1.5.0", "source": { "type": "git", - "url": "https://github.com/php-fig/simple-cache.git", - "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + "url": "https://github.com/ralphjsmit/laravel-seo.git", + "reference": "7671c6df3c70f7941538df795826595235757c52" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", - "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "url": "https://api.github.com/repos/ralphjsmit/laravel-seo/zipball/7671c6df3c70f7941538df795826595235757c52", + "reference": "7671c6df3c70f7941538df795826595235757c52", "shasum": "" }, "require": { - "php": ">=8.0.0" + "illuminate/contracts": "^9.0|^10.0|^11.0", + "php": "^8.0", + "ralphjsmit/laravel-helpers": "^1.9", + "spatie/laravel-package-tools": "^1.9.2" + }, + "require-dev": { + "nesbot/carbon": "^2.66|^3.0", + "nunomaduro/collision": "^5.10|^6.0|^7.0|^8.0", + "orchestra/testbench": "^7.0|^8.0|^9.0", + "pestphp/pest": "^1.21|^2.0", + "pestphp/pest-plugin-laravel": "^1.1|^2.0", + "phpunit/phpunit": "^9.5|^10.5", + "spatie/laravel-ray": "^1.26", + "spatie/pest-plugin-test-time": "^1.0|^2.0" }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" + "laravel": { + "providers": [ + "RalphJSmit\\Laravel\\SEO\\LaravelSEOServiceProvider" + ], + "aliases": { + "SEOManager": "RalphJSmit\\Laravel\\SEO\\Facades\\SEOManager" + } } }, "autoload": { + "files": [ + "src/helpers.php" + ], "psr-4": { - "Psr\\SimpleCache\\": "src/" + "RalphJSmit\\Laravel\\SEO\\": "src", + "RalphJSmit\\Laravel\\SEO\\Database\\Factories\\": "database/factories" } }, "notification-url": "https://packagist.org/downloads/", @@ -4407,22 +5046,23 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Ralph J. Smit", + "email": "rjs@ralphjsmit.com", + "role": "Developer" } ], - "description": "Common interfaces for simple caching", + "description": "A package to handle the SEO in any Laravel application, big or small.", + "homepage": "https://github.com/ralphjsmit/laravel-seo", "keywords": [ - "cache", - "caching", - "psr", - "psr-16", - "simple-cache" + "laravel", + "laravel-seo", + "ralphjsmit" ], "support": { - "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + "issues": "https://github.com/ralphjsmit/laravel-seo/issues", + "source": "https://github.com/ralphjsmit/laravel-seo/tree/1.5.0" }, - "time": "2021-10-29T13:26:27+00:00" + "time": "2024-03-14T08:37:33+00:00" }, { "name": "ramsey/collection", @@ -8158,122 +8798,6 @@ ], "time": "2023-11-03T12:00:00+00:00" }, - { - "name": "guzzlehttp/psr7", - "version": "2.6.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.36 || ^9.6.15" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.6.2" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", - "type": "tidelift" - } - ], - "time": "2023-12-03T20:05:35+00:00" - }, { "name": "hamcrest/hamcrest-php", "version": "v2.0.1", @@ -10686,50 +11210,6 @@ }, "time": "2023-12-20T15:28:09+00:00" }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, { "name": "rector/rector", "version": "1.0.2", @@ -12599,5 +13079,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Filament/Resources/AbstractContentResource.php b/src/Filament/Resources/AbstractContentResource.php index 629e0444..4b43e6c4 100644 --- a/src/Filament/Resources/AbstractContentResource.php +++ b/src/Filament/Resources/AbstractContentResource.php @@ -30,6 +30,7 @@ use Portable\FilaCms\Models\Page; use Portable\FilaCms\Models\Scopes\PublishedScope; use Portable\FilaCms\Models\TaxonomyResource; +use RalphJSmit\Filament\SEO\SEO; class AbstractContentResource extends AbstractResource { @@ -62,7 +63,8 @@ public static function form(Form $form): Form TextInput::make('title') ->columnSpanFull() ->required(), - static::tiptapEditor(), + static::tiptapEditor()->output(\FilamentTiptapEditor\Enums\TiptapOutput::Json), + SEO::make(['description']), ]), Tabs\Tab::make('Taxonomies') ->schema([ diff --git a/src/Models/AbstractContentModel.php b/src/Models/AbstractContentModel.php index 46975fad..424cc515 100644 --- a/src/Models/AbstractContentModel.php +++ b/src/Models/AbstractContentModel.php @@ -13,6 +13,8 @@ use Portable\FilaCms\Filament\Traits\HasTaxonomies; use Portable\FilaCms\Models\Scopes\PublishedScope; use Venturecraft\Revisionable\RevisionableTrait; +use RalphJSmit\Laravel\SEO\Support\HasSEO; +use RalphJSmit\Laravel\SEO\Support\SEOData; abstract class AbstractContentModel extends Model { @@ -20,6 +22,7 @@ abstract class AbstractContentModel extends Model use HasTaxonomies; use RevisionableTrait; use SoftDeletes; + use HasSEO; protected $table = 'contents'; @@ -61,6 +64,14 @@ protected static function booting(): void static::addGlobalScope(new PublishedScope()); } + public function getDynamicSEOData(): SEOData + { + return new SEOData( + title: $this->title, + author: $this->author?->display_name, + ); + } + public function author() { return $this->belongsTo(Author::class, 'author_id'); From 986037d1feca5f61709abe88068dc2792a6dc5c9 Mon Sep 17 00:00:00 2001 From: Jeremy Layson Date: Thu, 4 Apr 2024 12:49:12 +0800 Subject: [PATCH 2/6] Fixed test cases --- src/Commands/InstallCommand.php | 2 ++ src/Filament/Resources/AbstractContentResource.php | 1 - src/Models/AbstractContentModel.php | 1 + tests/Factories/PageFactory.php | 2 +- tests/Feature/PageTest.php | 12 ++++++------ tests/Filament/PageResourceTest.php | 2 +- tests/TestCase.php | 3 +++ 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 6c033763..cd595d0e 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -23,6 +23,8 @@ public function handle() $this->call('vendor:publish', ['--provider' => "Spatie\Permission\PermissionServiceProvider"]); $this->call('vendor:publish', ['--provider' => "Venturecraft\Revisionable\RevisionableServiceProvider"]); + $this->call('vendor:publish', ['--tag' => "seo-migrations"]); + $this->call('vendor:publish', ['--tag' => "seo-config"]); $this->info('Installed Spatie Permissions. Installing Fila CMS Config...'); diff --git a/src/Filament/Resources/AbstractContentResource.php b/src/Filament/Resources/AbstractContentResource.php index 4b43e6c4..76e4591e 100644 --- a/src/Filament/Resources/AbstractContentResource.php +++ b/src/Filament/Resources/AbstractContentResource.php @@ -156,7 +156,6 @@ public static function table(Table $table): Table return $table ->columns([ TextColumn::make('title') - ->description(fn (Page $page): string => substr($page->contents, 0, 50) . '...') ->sortable(), TextColumn::make('author.display_name')->label('Author') ->sortable(), diff --git a/src/Models/AbstractContentModel.php b/src/Models/AbstractContentModel.php index 424cc515..d0cd3ed5 100644 --- a/src/Models/AbstractContentModel.php +++ b/src/Models/AbstractContentModel.php @@ -47,6 +47,7 @@ abstract class AbstractContentModel extends Model protected $casts = [ 'publish_at' => 'datetime', 'expire_at' => 'datetime', + 'contents' => 'json', ]; protected $dispatchesEvents = [ diff --git a/tests/Factories/PageFactory.php b/tests/Factories/PageFactory.php index 37ecb468..cf969ed8 100644 --- a/tests/Factories/PageFactory.php +++ b/tests/Factories/PageFactory.php @@ -23,7 +23,7 @@ public function definition(): array 'is_draft' => $draft, 'publish_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, 'expire_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, - 'contents' => fake()->words($this->faker->numberBetween(50, 150), true), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), ]; } } diff --git a/tests/Feature/PageTest.php b/tests/Feature/PageTest.php index 5f6e8750..94d2e0fc 100644 --- a/tests/Feature/PageTest.php +++ b/tests/Feature/PageTest.php @@ -54,7 +54,7 @@ public function test_can_add_page(): void $page = Page::create([ 'title' => $title, 'is_draft' => 1, - 'contents' => $this->faker->paragraph(5), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), ]); $this->assertModelExists($page); @@ -79,7 +79,7 @@ public function test_custom_slug(): void 'title' => $title, 'slug' => 'test-slug', 'is_draft' => 1, - 'contents' => $this->faker->paragraph(5), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), ]); $this->assertDatabaseHas('pages', [ 'slug' => 'test-slug' ]); @@ -97,7 +97,7 @@ public function test_draft_status(): void 'is_draft' => 1, 'publish_at' => now()->subDays(10), 'expire_at' => now()->addDays(10), - 'contents' => $this->faker->paragraph(5), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), ]); $this->assertEquals($page->status, 'Draft'); @@ -114,7 +114,7 @@ public function test_published_status(): void 'is_draft' => 0, 'publish_at' => now()->subDays(10), 'expire_at' => now()->addDays(10), - 'contents' => $this->faker->paragraph(5), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), ]); $this->assertEquals($page->status, 'Published'); @@ -131,7 +131,7 @@ public function test_expired_status(): void 'is_draft' => 0, 'publish_at' => now()->subDays(10), 'expire_at' => now()->subDays(10), - 'contents' => $this->faker->paragraph(5), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), ]); $this->assertEquals($page->status, 'Expired'); @@ -148,7 +148,7 @@ public function test_pending_status(): void 'is_draft' => 0, 'publish_at' => now()->addDays(10), 'expire_at' => now()->addDays(10), - 'contents' => $this->faker->paragraph(5), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), ]); $this->assertEquals($page->status, 'Pending'); diff --git a/tests/Filament/PageResourceTest.php b/tests/Filament/PageResourceTest.php index e6cd4d15..856dd10a 100644 --- a/tests/Filament/PageResourceTest.php +++ b/tests/Filament/PageResourceTest.php @@ -179,7 +179,7 @@ public function generateModel($raw = false): TargetModel|array 'is_draft' => $draft, 'publish_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, 'expire_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, - 'contents' => $this->faker->words($this->faker->numberBetween(50, 150), true), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), 'author_Id' => $this->author->id, ]; diff --git a/tests/TestCase.php b/tests/TestCase.php index 1da97e69..a84312cf 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -29,6 +29,7 @@ protected function setUp(): void // remove config files File::delete(config_path('fila-cms.php')); + File::delete(config_path('seo.php')); File::delete(config_path('filament-tiptap-editor.php')); // remove migrations from revisionable @@ -76,6 +77,8 @@ protected function getPackageProviders($app) $packages[] = \Spatie\Permission\PermissionServiceProvider::class; $packages[] = \Laravel\Sanctum\SanctumServiceProvider::class; $packages[] = \Portable\FilaCms\Providers\FilaCmsServiceProvider::class; + $packages[] = \Portable\FilaCms\Providers\FilaCmsServiceProvider::class; + $packages[] = \RalphJSmit\Laravel\SEO\LaravelSEOServiceProvider::class; /* */ // App\Providers\BroadcastServiceProvider::class, From 9b1f05317451ee3e89da4ed5c170329ec323ca04 Mon Sep 17 00:00:00 2001 From: Jeremy Layson Date: Thu, 4 Apr 2024 12:49:54 +0800 Subject: [PATCH 3/6] Fixed Lint --- tests/Factories/PageFactory.php | 2 +- tests/Feature/PageTest.php | 12 ++++++------ tests/Filament/PageResourceTest.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Factories/PageFactory.php b/tests/Factories/PageFactory.php index cf969ed8..49f05fbb 100644 --- a/tests/Factories/PageFactory.php +++ b/tests/Factories/PageFactory.php @@ -23,7 +23,7 @@ public function definition(): array 'is_draft' => $draft, 'publish_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, 'expire_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), ]; } } diff --git a/tests/Feature/PageTest.php b/tests/Feature/PageTest.php index 94d2e0fc..70ce837b 100644 --- a/tests/Feature/PageTest.php +++ b/tests/Feature/PageTest.php @@ -54,7 +54,7 @@ public function test_can_add_page(): void $page = Page::create([ 'title' => $title, 'is_draft' => 1, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), ]); $this->assertModelExists($page); @@ -79,7 +79,7 @@ public function test_custom_slug(): void 'title' => $title, 'slug' => 'test-slug', 'is_draft' => 1, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), ]); $this->assertDatabaseHas('pages', [ 'slug' => 'test-slug' ]); @@ -97,7 +97,7 @@ public function test_draft_status(): void 'is_draft' => 1, 'publish_at' => now()->subDays(10), 'expire_at' => now()->addDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), ]); $this->assertEquals($page->status, 'Draft'); @@ -114,7 +114,7 @@ public function test_published_status(): void 'is_draft' => 0, 'publish_at' => now()->subDays(10), 'expire_at' => now()->addDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), ]); $this->assertEquals($page->status, 'Published'); @@ -131,7 +131,7 @@ public function test_expired_status(): void 'is_draft' => 0, 'publish_at' => now()->subDays(10), 'expire_at' => now()->subDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), ]); $this->assertEquals($page->status, 'Expired'); @@ -148,7 +148,7 @@ public function test_pending_status(): void 'is_draft' => 0, 'publish_at' => now()->addDays(10), 'expire_at' => now()->addDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), ]); $this->assertEquals($page->status, 'Pending'); diff --git a/tests/Filament/PageResourceTest.php b/tests/Filament/PageResourceTest.php index 856dd10a..826a28fb 100644 --- a/tests/Filament/PageResourceTest.php +++ b/tests/Filament/PageResourceTest.php @@ -179,7 +179,7 @@ public function generateModel($raw = false): TargetModel|array 'is_draft' => $draft, 'publish_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, 'expire_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', TRUE), + 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), 'author_Id' => $this->author->id, ]; From 35ee6b66fbca70070b273f49bbe3bb4dbb87527f Mon Sep 17 00:00:00 2001 From: Jeremy Layson Date: Thu, 4 Apr 2024 12:55:56 +0800 Subject: [PATCH 4/6] Added back description in table --- src/Filament/Resources/AbstractContentResource.php | 1 + src/Models/AbstractContentModel.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Filament/Resources/AbstractContentResource.php b/src/Filament/Resources/AbstractContentResource.php index 76e4591e..4b43e6c4 100644 --- a/src/Filament/Resources/AbstractContentResource.php +++ b/src/Filament/Resources/AbstractContentResource.php @@ -156,6 +156,7 @@ public static function table(Table $table): Table return $table ->columns([ TextColumn::make('title') + ->description(fn (Page $page): string => substr($page->contents, 0, 50) . '...') ->sortable(), TextColumn::make('author.display_name')->label('Author') ->sortable(), diff --git a/src/Models/AbstractContentModel.php b/src/Models/AbstractContentModel.php index d0cd3ed5..424cc515 100644 --- a/src/Models/AbstractContentModel.php +++ b/src/Models/AbstractContentModel.php @@ -47,7 +47,6 @@ abstract class AbstractContentModel extends Model protected $casts = [ 'publish_at' => 'datetime', 'expire_at' => 'datetime', - 'contents' => 'json', ]; protected $dispatchesEvents = [ From 3904cce46c96424e4d904ebacda89bb5e198f01e Mon Sep 17 00:00:00 2001 From: Jeremy Layson Date: Thu, 4 Apr 2024 14:32:54 +0800 Subject: [PATCH 5/6] Fixed Excerpt --- .../Resources/AbstractContentResource.php | 2 +- src/Filament/Traits/HasExcerpt.php | 16 ++++- src/Models/AbstractContentModel.php | 1 + tests/Factories/PageFactory.php | 30 ++++++++- tests/Feature/PageTest.php | 61 ++++++------------- tests/Filament/PageResourceTest.php | 28 ++++++++- 6 files changed, 88 insertions(+), 50 deletions(-) diff --git a/src/Filament/Resources/AbstractContentResource.php b/src/Filament/Resources/AbstractContentResource.php index 4b43e6c4..67a96b33 100644 --- a/src/Filament/Resources/AbstractContentResource.php +++ b/src/Filament/Resources/AbstractContentResource.php @@ -156,7 +156,7 @@ public static function table(Table $table): Table return $table ->columns([ TextColumn::make('title') - ->description(fn (Page $page): string => substr($page->contents, 0, 50) . '...') + ->description(fn (Page $page): string => $page->excerpt) ->sortable(), TextColumn::make('author.display_name')->label('Author') ->sortable(), diff --git a/src/Filament/Traits/HasExcerpt.php b/src/Filament/Traits/HasExcerpt.php index eec88a42..188c52f6 100644 --- a/src/Filament/Traits/HasExcerpt.php +++ b/src/Filament/Traits/HasExcerpt.php @@ -11,9 +11,19 @@ trait HasExcerpt public function excerpt(): Attribute { - return Attribute::make(function () { - return Str::take(Str::of($this->{$this->excerptField} ?? '')->stripTags(), 200); - }); + $excerpt = $this->{$this->excerptField}; + $content = $excerpt['content']; + + // get first content with "paragraph" + $paragraph = ''; + foreach ($content as $key => $value) { + if ($value['type'] === 'paragraph') { + $paragraph = $value['content'][0]['text']; // take the first part + } + } + return Attribute::make(function () use ($paragraph) { + return Str::take(Str::of($paragraph)->stripTags(), 200); + }); } } diff --git a/src/Models/AbstractContentModel.php b/src/Models/AbstractContentModel.php index 424cc515..d0cd3ed5 100644 --- a/src/Models/AbstractContentModel.php +++ b/src/Models/AbstractContentModel.php @@ -47,6 +47,7 @@ abstract class AbstractContentModel extends Model protected $casts = [ 'publish_at' => 'datetime', 'expire_at' => 'datetime', + 'contents' => 'json', ]; protected $dispatchesEvents = [ diff --git a/tests/Factories/PageFactory.php b/tests/Factories/PageFactory.php index 49f05fbb..9e1612e5 100644 --- a/tests/Factories/PageFactory.php +++ b/tests/Factories/PageFactory.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Factories\Factory; use Portable\FilaCms\Models\Page; +use Str; class PageFactory extends Factory { @@ -17,13 +18,38 @@ class PageFactory extends Factory public function definition(): array { $draft = fake()->numberBetween(0, 1); + $title = fake()->words(15, true); return [ - 'title' => fake()->words(15, true), + 'title' => $title, + 'slug' => Str::slug($title), 'is_draft' => $draft, 'publish_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, 'expire_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), + 'contents' => $this->createContent(), + ]; + } + + protected function createContent() + { + return [ + 'type' => 'doc', + 'content' => [ + [ + 'type' => 'paragraph', + 'attrs' => [ + 'class' => null, + 'style' => null, + 'textAlign' => 'start', + ], + 'content' => [ + [ + 'text' => fake()->words(mt_rand(10, 50), true), + 'type' => 'text' + ] + ] + ] + ] ]; } } diff --git a/tests/Feature/PageTest.php b/tests/Feature/PageTest.php index 70ce837b..b2f620d0 100644 --- a/tests/Feature/PageTest.php +++ b/tests/Feature/PageTest.php @@ -50,15 +50,10 @@ public function test_can_add_page(): void 'password' => 'password' ]); - $title = $this->faker->text; - $page = Page::create([ - 'title' => $title, - 'is_draft' => 1, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), - ]); + $page = Page::factory()->create(); $this->assertModelExists($page); - $this->assertDatabaseHas('pages', [ 'slug' => Str::slug($title) ]); + $this->assertDatabaseHas('pages', [ 'slug' => Str::slug($page->title) ]); $this->assertEquals($page->created_user_id, $user->id); $this->be($secondUser); @@ -74,16 +69,12 @@ public function test_custom_slug(): void $author = Author::first(); $user = $this->userModel::first(); - $title = $this->faker->text; - $page = Page::create([ - 'title' => $title, - 'slug' => 'test-slug', - 'is_draft' => 1, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), + $page = Page::factory()->create([ + 'slug' => 'test-slug', ]); $this->assertDatabaseHas('pages', [ 'slug' => 'test-slug' ]); - $this->assertDatabaseMissing('pages', [ 'slug' => Str::slug($title) ]); + $this->assertDatabaseMissing('pages', [ 'slug' => Str::slug($page->title) ]); } public function test_draft_status(): void @@ -91,13 +82,8 @@ public function test_draft_status(): void $author = Author::first(); $user = $this->userModel::first(); - $title = $this->faker->text; - $page = Page::create([ - 'title' => $title, - 'is_draft' => 1, - 'publish_at' => now()->subDays(10), - 'expire_at' => now()->addDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), + $page = Page::factory()->create([ + 'is_draft' => 1, ]); $this->assertEquals($page->status, 'Draft'); @@ -108,13 +94,10 @@ public function test_published_status(): void $author = Author::first(); $user = $this->userModel::first(); - $title = $this->faker->text; - $page = Page::create([ - 'title' => $title, - 'is_draft' => 0, - 'publish_at' => now()->subDays(10), - 'expire_at' => now()->addDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), + $page = Page::factory()->create([ + 'is_draft' => 0, + 'publish_at' => $this->faker->dateTimeBetween('-1 week', '-1 day'), + 'expire_at' => $this->faker->dateTimeBetween('+1 day', '+1 week'), ]); $this->assertEquals($page->status, 'Published'); @@ -125,13 +108,10 @@ public function test_expired_status(): void $author = Author::first(); $user = $this->userModel::first(); - $title = $this->faker->text; - $page = Page::create([ - 'title' => $title, - 'is_draft' => 0, - 'publish_at' => now()->subDays(10), - 'expire_at' => now()->subDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), + $page = Page::factory()->create([ + 'is_draft' => 0, + 'publish_at' => $this->faker->dateTimeBetween('-1 week', '-1 day'), + 'expire_at' => $this->faker->dateTimeBetween('-1 week', '-1 day'), ]); $this->assertEquals($page->status, 'Expired'); @@ -142,13 +122,10 @@ public function test_pending_status(): void $author = Author::first(); $user = $this->userModel::first(); - $title = $this->faker->text; - $page = Page::create([ - 'title' => $title, - 'is_draft' => 0, - 'publish_at' => now()->addDays(10), - 'expire_at' => now()->addDays(10), - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), + $page = Page::factory()->create([ + 'is_draft' => 0, + 'publish_at' => $this->faker->dateTimeBetween('+1 day', '+1 week'), + 'expire_at' => $this->faker->dateTimeBetween('+1 day', '+1 week'), ]); $this->assertEquals($page->status, 'Pending'); diff --git a/tests/Filament/PageResourceTest.php b/tests/Filament/PageResourceTest.php index 826a28fb..0a53b64f 100644 --- a/tests/Filament/PageResourceTest.php +++ b/tests/Filament/PageResourceTest.php @@ -157,7 +157,7 @@ public function test_can_create_page_with_taxonomies(): void ->fillForm([ 'is_draft' => 0, 'title' => 'Test Page', - 'contents' => 'Test Page Contents', + 'contents' => $this->createContent(), 'colours_ids' => [$red->id], ]) ->call('create') @@ -179,7 +179,7 @@ public function generateModel($raw = false): TargetModel|array 'is_draft' => $draft, 'publish_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, 'expire_at' => $draft === 1 ? $this->faker->dateTimeBetween('-1 week', '+1 week') : null, - 'contents' => json_decode('{"type": "doc", "content": [{"type": "paragraph", "attrs": {"class": null, "style": null, "textAlign": "start"}, "content": [{"text": "Lorem ipsum keme keme keme 48 years chaka biway chapter ano kemerloo at nang ng shontis at klapeypey-klapeypey katagalugan katagalugan nang sa at na ang jowabella buya daki nang makyonget biway chaka shongaers lorem ipsum keme keme chipipay intonses shontis at nang at bakit bella kasi lulu shonga-shonga lorem ipsum keme keme buya ano jutay ma-kyonget wasok otoko at bakit juts kirara at nang na ang shogal bella na ang kabog majubis jowabella at kabog bakit otoko at ang na ang 48 years at ang nakakalurky pranella shonga chopopo ng at chuckie na at nang bella kasi chopopo nang valaj ng shokot chipipay kasi tungril guash sangkatuts lulu ano majonders ganda lang kabog sa warla sa jutay biway at bakit matod majubis sa bonggakea jowabella oblation wiz shonga-shonga.", "type": "text"}]}]}', true), + 'contents' => $this->createContent(), 'author_Id' => $this->author->id, ]; @@ -189,4 +189,28 @@ public function generateModel($raw = false): TargetModel|array return TargetModel::create($data); } + + + protected function createContent() + { + return [ + 'type' => 'doc', + 'content' => [ + [ + 'type' => 'paragraph', + 'attrs' => [ + 'class' => null, + 'style' => null, + 'textAlign' => 'start', + ], + 'content' => [ + [ + 'text' => fake()->words(mt_rand(10, 50), true), + 'type' => 'text' + ] + ] + ] + ] + ]; + } } From d203054d80c299c9da666912e8e897e11aa29370 Mon Sep 17 00:00:00 2001 From: Jeremy Layson Date: Thu, 4 Apr 2024 15:17:27 +0800 Subject: [PATCH 6/6] Fix lInt --- tests/Filament/PageResourceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Filament/PageResourceTest.php b/tests/Filament/PageResourceTest.php index 0a53b64f..757e86d0 100644 --- a/tests/Filament/PageResourceTest.php +++ b/tests/Filament/PageResourceTest.php @@ -190,7 +190,7 @@ public function generateModel($raw = false): TargetModel|array return TargetModel::create($data); } - + protected function createContent() { return [