diff --git a/app/Events/BookRecommendation/BookRecommendationCreated.php b/app/Events/BookRecommendation/BookRecommendationCreated.php new file mode 100644 index 0000000..e25f09a --- /dev/null +++ b/app/Events/BookRecommendation/BookRecommendationCreated.php @@ -0,0 +1,42 @@ + + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('BookRecommendation'), + ]; + } +} diff --git a/app/Events/BookRecommendation/BookRecommendationDeleted.php b/app/Events/BookRecommendation/BookRecommendationDeleted.php new file mode 100644 index 0000000..ea1f76b --- /dev/null +++ b/app/Events/BookRecommendation/BookRecommendationDeleted.php @@ -0,0 +1,42 @@ + + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('BookRecommendation'), + ]; + } +} diff --git a/app/Events/BookRecommendation/BookRecommendationUpdated.php b/app/Events/BookRecommendation/BookRecommendationUpdated.php new file mode 100644 index 0000000..f7e630f --- /dev/null +++ b/app/Events/BookRecommendation/BookRecommendationUpdated.php @@ -0,0 +1,42 @@ + + */ + public function broadcastOn(): array + { + return [ + new PrivateChannel('BookRecommendation'), + ]; + } +} diff --git a/app/Models/BookRecommendation.php b/app/Models/BookRecommendation.php index 2cca29d..53851f4 100644 --- a/app/Models/BookRecommendation.php +++ b/app/Models/BookRecommendation.php @@ -2,7 +2,12 @@ namespace App\Models; +use App\Events\BookRecommendation\BookRecommendationCreated; +use App\Events\BookRecommendation\BookRecommendationDeleted; +use App\Events\BookRecommendation\BookRecommendationUpdated; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class BookRecommendation extends Model { @@ -20,20 +25,35 @@ class BookRecommendation extends Model 'published_at', ]; + protected static function booted() :void + { + static::created(static function ($bookRecommendation) { + broadcast(new BookRecommendationCreated($bookRecommendation))->toOthers(); + }); + + static::updated(static function ($task) { + broadcast(new BookRecommendationUpdated($task))->toOthers(); + }); + + static::deleting(static function ($task) { + broadcast(new BookRecommendationDeleted($task))->toOthers(); + }); + } + /** * Get the user that recommended the book. */ - public function recommender() + public function recommender(): BelongsTo { return $this->belongsTo(User::class, 'recommended_by'); } - public function votes() + public function votes(): HasMany { return $this->hasMany(Vote::class); } - public function deadlines() + public function deadlines(): HasMany { return $this->hasMany(Deadline::class); } diff --git a/bootstrap/app.php b/bootstrap/app.php index 2f15486..5327a1f 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -14,6 +14,7 @@ return Application::configure(basePath: dirname(__DIR__)) api: __DIR__.'/../routes/api.php', apiPrefix: '', commands: __DIR__.'/../routes/console.php', + channels: __DIR__.'/../routes/channels.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { diff --git a/composer.json b/composer.json index 3dee6dd..9742b7e 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "laravel/tinker": "^2.9", "league/flysystem-aws-s3-v3": "^3.24", "predis/predis": "*", + "pusher/pusher-php-server": "^7.2", "spatie/laravel-permission": "^6.4" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 1282b96..0d9b9c8 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": "ec31886b4063db8aa1efc22c187f614a", + "content-hash": "572762c5d2b5b91e9a8012b47f3cd07f", "packages": [ { "name": "aws/aws-crt-php", @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.301.1", + "version": "3.301.6", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "0a910d2b35e7087337cdf3569dc9b6ce232aafba" + "reference": "18c0ebd71d3071304f1ea02aa9af75f95863177a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/0a910d2b35e7087337cdf3569dc9b6ce232aafba", - "reference": "0a910d2b35e7087337cdf3569dc9b6ce232aafba", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/18c0ebd71d3071304f1ea02aa9af75f95863177a", + "reference": "18c0ebd71d3071304f1ea02aa9af75f95863177a", "shasum": "" }, "require": { @@ -151,9 +151,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.301.1" + "source": "https://github.com/aws/aws-sdk-php/tree/3.301.6" }, - "time": "2024-03-15T18:14:42+00:00" + "time": "2024-03-22T18:05:21+00:00" }, { "name": "brick/math", @@ -1408,16 +1408,16 @@ }, { "name": "intervention/image", - "version": "3.4.0", + "version": "3.5.0", "source": { "type": "git", "url": "https://github.com/Intervention/image.git", - "reference": "fe1b0e2e64157133322974c28b44c25c2770a0c5" + "reference": "408d3655c7705339e8c79731ea7efb51546cfa10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Intervention/image/zipball/fe1b0e2e64157133322974c28b44c25c2770a0c5", - "reference": "fe1b0e2e64157133322974c28b44c25c2770a0c5", + "url": "https://api.github.com/repos/Intervention/image/zipball/408d3655c7705339e8c79731ea7efb51546cfa10", + "reference": "408d3655c7705339e8c79731ea7efb51546cfa10", "shasum": "" }, "require": { @@ -1428,7 +1428,7 @@ "require-dev": { "mockery/mockery": "^1.6", "phpstan/phpstan": "^1", - "phpunit/phpunit": "^9", + "phpunit/phpunit": "^10.0", "slevomat/coding-standard": "~8.0", "squizlabs/php_codesniffer": "^3.8" }, @@ -1464,7 +1464,7 @@ ], "support": { "issues": "https://github.com/Intervention/image/issues", - "source": "https://github.com/Intervention/image/tree/3.4.0" + "source": "https://github.com/Intervention/image/tree/3.5.0" }, "funding": [ { @@ -1476,20 +1476,20 @@ "type": "github" } ], - "time": "2024-02-14T15:11:21+00:00" + "time": "2024-03-13T16:26:15+00:00" }, { "name": "jaybizzle/crawler-detect", - "version": "v1.2.116", + "version": "v1.2.117", "source": { "type": "git", "url": "https://github.com/JayBizzle/Crawler-Detect.git", - "reference": "97e9fe30219e60092e107651abb379a38b342921" + "reference": "6785557f03d0fa9e2205352ebae9a12a4484cc8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/97e9fe30219e60092e107651abb379a38b342921", - "reference": "97e9fe30219e60092e107651abb379a38b342921", + "url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/6785557f03d0fa9e2205352ebae9a12a4484cc8e", + "reference": "6785557f03d0fa9e2205352ebae9a12a4484cc8e", "shasum": "" }, "require": { @@ -1526,9 +1526,9 @@ ], "support": { "issues": "https://github.com/JayBizzle/Crawler-Detect/issues", - "source": "https://github.com/JayBizzle/Crawler-Detect/tree/v1.2.116" + "source": "https://github.com/JayBizzle/Crawler-Detect/tree/v1.2.117" }, - "time": "2023-07-21T15:49:49+00:00" + "time": "2024-03-19T22:51:22+00:00" }, { "name": "laminas/laminas-diactoros", @@ -1617,16 +1617,16 @@ }, { "name": "laravel/framework", - "version": "v11.0.7", + "version": "v11.0.8", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "28eabe9dcdcb017a21ce226eda4538c5c8c93b1c" + "reference": "0379a7ccb77e2029c43ce508fa76e251a0d68fce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/28eabe9dcdcb017a21ce226eda4538c5c8c93b1c", - "reference": "28eabe9dcdcb017a21ce226eda4538c5c8c93b1c", + "url": "https://api.github.com/repos/laravel/framework/zipball/0379a7ccb77e2029c43ce508fa76e251a0d68fce", + "reference": "0379a7ccb77e2029c43ce508fa76e251a0d68fce", "shasum": "" }, "require": { @@ -1729,7 +1729,7 @@ "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.6", "nyholm/psr7": "^1.2", - "orchestra/testbench-core": "^9.0", + "orchestra/testbench-core": "^9.0.6", "pda/pheanstalk": "^5.0", "phpstan/phpstan": "^1.4.7", "phpunit/phpunit": "^10.5|^11.0", @@ -1818,7 +1818,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-03-15T23:17:58+00:00" + "time": "2024-03-21T14:15:49+00:00" }, { "name": "laravel/octane", @@ -2414,16 +2414,16 @@ }, { "name": "league/flysystem", - "version": "3.25.0", + "version": "3.25.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "4c44347133618cccd9b3df1729647a1577b4ad99" + "reference": "abbd664eb4381102c559d358420989f835208f18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/4c44347133618cccd9b3df1729647a1577b4ad99", - "reference": "4c44347133618cccd9b3df1729647a1577b4ad99", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/abbd664eb4381102c559d358420989f835208f18", + "reference": "abbd664eb4381102c559d358420989f835208f18", "shasum": "" }, "require": { @@ -2488,7 +2488,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.25.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.25.1" }, "funding": [ { @@ -2500,20 +2500,20 @@ "type": "github" } ], - "time": "2024-03-09T17:06:45+00:00" + "time": "2024-03-16T12:53:19+00:00" }, { "name": "league/flysystem-aws-s3-v3", - "version": "3.24.0", + "version": "3.25.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git", - "reference": "809474e37b7fb1d1f8bcc0f8a98bc1cae99aa513" + "reference": "6a5be0e6d6a93574e80805c9cc108a4b63c824d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/809474e37b7fb1d1f8bcc0f8a98bc1cae99aa513", - "reference": "809474e37b7fb1d1f8bcc0f8a98bc1cae99aa513", + "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/6a5be0e6d6a93574e80805c9cc108a4b63c824d8", + "reference": "6a5be0e6d6a93574e80805c9cc108a4b63c824d8", "shasum": "" }, "require": { @@ -2553,7 +2553,7 @@ "storage" ], "support": { - "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.24.0" + "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.25.1" }, "funding": [ { @@ -2565,20 +2565,20 @@ "type": "github" } ], - "time": "2024-01-26T18:43:21+00:00" + "time": "2024-03-15T19:58:44+00:00" }, { "name": "league/flysystem-local", - "version": "3.23.1", + "version": "3.25.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem-local.git", - "reference": "b884d2bf9b53bb4804a56d2df4902bb51e253f00" + "reference": "61a6a90d6e999e4ddd9ce5adb356de0939060b92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/b884d2bf9b53bb4804a56d2df4902bb51e253f00", - "reference": "b884d2bf9b53bb4804a56d2df4902bb51e253f00", + "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/61a6a90d6e999e4ddd9ce5adb356de0939060b92", + "reference": "61a6a90d6e999e4ddd9ce5adb356de0939060b92", "shasum": "" }, "require": { @@ -2612,8 +2612,7 @@ "local" ], "support": { - "issues": "https://github.com/thephpleague/flysystem-local/issues", - "source": "https://github.com/thephpleague/flysystem-local/tree/3.23.1" + "source": "https://github.com/thephpleague/flysystem-local/tree/3.25.1" }, "funding": [ { @@ -2625,7 +2624,7 @@ "type": "github" } ], - "time": "2024-01-26T18:25:23+00:00" + "time": "2024-03-15T19:58:44+00:00" }, { "name": "league/mime-type-detection", @@ -3570,6 +3569,142 @@ ], "time": "2024-03-06T16:17:14+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, + { + "name": "paragonie/sodium_compat", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/paragonie/sodium_compat.git", + "reference": "e592a3e06d1fa0d43988c7c7d9948ca836f644b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/e592a3e06d1fa0d43988c7c7d9948ca836f644b6", + "reference": "e592a3e06d1fa0d43988c7c7d9948ca836f644b6", + "shasum": "" + }, + "require": { + "paragonie/random_compat": ">=1", + "php": "^5.2.4|^5.3|^5.4|^5.5|^5.6|^7|^8" + }, + "require-dev": { + "phpunit/phpunit": "^3|^4|^5|^6|^7|^8|^9" + }, + "suggest": { + "ext-libsodium": "PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.", + "ext-sodium": "PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security." + }, + "type": "library", + "autoload": { + "files": [ + "autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com" + }, + { + "name": "Frank Denis", + "email": "jedisct1@pureftpd.org" + } + ], + "description": "Pure PHP implementation of libsodium; uses the PHP extension if it exists", + "keywords": [ + "Authentication", + "BLAKE2b", + "ChaCha20", + "ChaCha20-Poly1305", + "Chapoly", + "Curve25519", + "Ed25519", + "EdDSA", + "Edwards-curve Digital Signature Algorithm", + "Elliptic Curve Diffie-Hellman", + "Poly1305", + "Pure-PHP cryptography", + "RFC 7748", + "RFC 8032", + "Salpoly", + "Salsa20", + "X25519", + "XChaCha20-Poly1305", + "XSalsa20-Poly1305", + "Xchacha20", + "Xsalsa20", + "aead", + "cryptography", + "ecdh", + "elliptic curve", + "elliptic curve cryptography", + "encryption", + "libsodium", + "php", + "public-key cryptography", + "secret-key cryptography", + "side-channel resistant" + ], + "support": { + "issues": "https://github.com/paragonie/sodium_compat/issues", + "source": "https://github.com/paragonie/sodium_compat/tree/v1.20.0" + }, + "time": "2023-04-30T00:54:53+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.2", @@ -4120,16 +4255,16 @@ }, { "name": "psy/psysh", - "version": "v0.12.1", + "version": "v0.12.2", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "39621c73e0754328252f032c6997b983afc50431" + "reference": "9185c66c2165bbf4d71de78a69dccf4974f9538d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/39621c73e0754328252f032c6997b983afc50431", - "reference": "39621c73e0754328252f032c6997b983afc50431", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/9185c66c2165bbf4d71de78a69dccf4974f9538d", + "reference": "9185c66c2165bbf4d71de78a69dccf4974f9538d", "shasum": "" }, "require": { @@ -4193,9 +4328,70 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.12.1" + "source": "https://github.com/bobthecow/psysh/tree/v0.12.2" }, - "time": "2024-03-15T03:22:57+00:00" + "time": "2024-03-17T01:53:00+00:00" + }, + { + "name": "pusher/pusher-php-server", + "version": "7.2.4", + "source": { + "type": "git", + "url": "https://github.com/pusher/pusher-http-php.git", + "reference": "de2f72296808f9cafa6a4462b15a768ff130cddb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/de2f72296808f9cafa6a4462b15a768ff130cddb", + "reference": "de2f72296808f9cafa6a4462b15a768ff130cddb", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "guzzlehttp/guzzle": "^7.2", + "paragonie/sodium_compat": "^1.6", + "php": "^7.3|^8.0", + "psr/log": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "overtrue/phplint": "^2.3", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Pusher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Library for interacting with the Pusher REST API", + "keywords": [ + "events", + "messaging", + "php-pusher-server", + "publish", + "push", + "pusher", + "real time", + "real-time", + "realtime", + "rest", + "trigger" + ], + "support": { + "issues": "https://github.com/pusher/pusher-http-php/issues", + "source": "https://github.com/pusher/pusher-http-php/tree/7.2.4" + }, + "time": "2023-12-15T10:58:53+00:00" }, { "name": "ralouphie/getallheaders", @@ -7438,16 +7634,16 @@ }, { "name": "composer/pcre", - "version": "3.1.2", + "version": "3.1.3", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4775f35b2d70865807c89d32c8e7385b86eb0ace" + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4775f35b2d70865807c89d32c8e7385b86eb0ace", - "reference": "4775f35b2d70865807c89d32c8e7385b86eb0ace", + "url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", "shasum": "" }, "require": { @@ -7489,7 +7685,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.2" + "source": "https://github.com/composer/pcre/tree/3.1.3" }, "funding": [ { @@ -7505,7 +7701,7 @@ "type": "tidelift" } ], - "time": "2024-03-07T15:38:35+00:00" + "time": "2024-03-19T10:26:25+00:00" }, { "name": "doctrine/deprecations", @@ -7807,16 +8003,16 @@ }, { "name": "laravel/sail", - "version": "v1.29.0", + "version": "v1.29.1", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "e40cc7ffb5186c45698dbd47e9477e0e429396d0" + "reference": "8be4a31150eab3b46af11a2e7b2c4632eefaad7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/e40cc7ffb5186c45698dbd47e9477e0e429396d0", - "reference": "e40cc7ffb5186c45698dbd47e9477e0e429396d0", + "url": "https://api.github.com/repos/laravel/sail/zipball/8be4a31150eab3b46af11a2e7b2c4632eefaad7e", + "reference": "8be4a31150eab3b46af11a2e7b2c4632eefaad7e", "shasum": "" }, "require": { @@ -7824,6 +8020,7 @@ "illuminate/contracts": "^9.52.16|^10.0|^11.0", "illuminate/support": "^9.52.16|^10.0|^11.0", "php": "^8.0", + "symfony/console": "^6.0|^7.0", "symfony/yaml": "^6.0|^7.0" }, "require-dev": { @@ -7865,7 +8062,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2024-03-08T16:32:33+00:00" + "time": "2024-03-20T20:09:31+00:00" }, { "name": "laravel/telescope", @@ -7937,16 +8134,16 @@ }, { "name": "mockery/mockery", - "version": "1.6.9", + "version": "1.6.11", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "0cc058854b3195ba21dc6b1f7b1f60f4ef3a9c06" + "reference": "81a161d0b135df89951abd52296adf97deb0723d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/0cc058854b3195ba21dc6b1f7b1f60f4ef3a9c06", - "reference": "0cc058854b3195ba21dc6b1f7b1f60f4ef3a9c06", + "url": "https://api.github.com/repos/mockery/mockery/zipball/81a161d0b135df89951abd52296adf97deb0723d", + "reference": "81a161d0b135df89951abd52296adf97deb0723d", "shasum": "" }, "require": { @@ -7958,8 +8155,8 @@ "phpunit/phpunit": "<8.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.6.10", - "symplify/easy-coding-standard": "^12.0.8" + "phpunit/phpunit": "^8.5 || ^9.6.17", + "symplify/easy-coding-standard": "^12.1.14" }, "type": "library", "autoload": { @@ -8016,7 +8213,7 @@ "security": "https://github.com/mockery/mockery/security/advisories", "source": "https://github.com/mockery/mockery" }, - "time": "2023-12-10T02:24:34+00:00" + "time": "2024-03-21T18:34:15+00:00" }, { "name": "myclabs/deep-copy", @@ -8405,16 +8602,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.26.0", + "version": "1.27.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227" + "reference": "86e4d5a4b036f8f0be1464522f4c6b584c452757" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/231e3186624c03d7e7c890ec662b81e6b0405227", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/86e4d5a4b036f8f0be1464522f4c6b584c452757", + "reference": "86e4d5a4b036f8f0be1464522f4c6b584c452757", "shasum": "" }, "require": { @@ -8446,9 +8643,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.26.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.27.0" }, - "time": "2024-02-23T16:05:55+00:00" + "time": "2024-03-21T13:14:53+00:00" }, { "name": "phpunit/php-code-coverage", @@ -8773,16 +8970,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.13", + "version": "10.5.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "20a63fc1c6db29b15da3bd02d4b6cf59900088a7" + "reference": "86376e05e8745ed81d88232ff92fee868247b07b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/20a63fc1c6db29b15da3bd02d4b6cf59900088a7", - "reference": "20a63fc1c6db29b15da3bd02d4b6cf59900088a7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/86376e05e8745ed81d88232ff92fee868247b07b", + "reference": "86376e05e8745ed81d88232ff92fee868247b07b", "shasum": "" }, "require": { @@ -8854,7 +9051,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.13" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.15" }, "funding": [ { @@ -8870,7 +9067,7 @@ "type": "tidelift" } ], - "time": "2024-03-12T15:37:41+00:00" + "time": "2024-03-22T04:17:47+00:00" }, { "name": "sebastian/cli-parser", diff --git a/config/broadcasting.php b/config/broadcasting.php new file mode 100644 index 0000000..ebc3fb9 --- /dev/null +++ b/config/broadcasting.php @@ -0,0 +1,82 @@ + env('BROADCAST_CONNECTION', 'null'), + + /* + |-------------------------------------------------------------------------- + | Broadcast Connections + |-------------------------------------------------------------------------- + | + | Here you may define all of the broadcast connections that will be used + | to broadcast events to other systems or over WebSockets. Samples of + | each available type of connection are provided inside this array. + | + */ + + 'connections' => [ + + 'reverb' => [ + 'driver' => 'reverb', + 'key' => env('REVERB_APP_KEY'), + 'secret' => env('REVERB_APP_SECRET'), + 'app_id' => env('REVERB_APP_ID'), + 'options' => [ + 'host' => env('REVERB_HOST'), + 'port' => env('REVERB_PORT', 443), + 'scheme' => env('REVERB_SCHEME', 'https'), + 'useTLS' => env('REVERB_SCHEME', 'https') === 'https', + ], + 'client_options' => [ + // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html + ], + ], + + 'pusher' => [ + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), + 'options' => [ + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', + 'port' => env('PUSHER_PORT', 443), + 'scheme' => env('PUSHER_SCHEME', 'https'), + 'encrypted' => true, + 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', + ], + 'client_options' => [ + // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html + ], + ], + + 'ably' => [ + 'driver' => 'ably', + 'key' => env('ABLY_KEY'), + ], + + 'log' => [ + 'driver' => 'log', + ], + + 'null' => [ + 'driver' => 'null', + ], + + ], + +]; diff --git a/nuxt.config.ts b/nuxt.config.ts index b17c194..fae9cf5 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -83,6 +83,17 @@ export default defineNuxtConfig({ color: 'gray', }, }, + echo: { + broadcaster: process.env.BROADCAST_CONNECTION, + key: process.env.PUSHER_APP_KEY, + cluster: process.env.PUSHER_APP_CLUSTER, + wsHost: process.env.PUSHER_APP_HOST, + wsPort: process.env.PUSHER_APP_PORT, + forceTLS: process.env.PUSHER_APP_TLS, + encrypted: process.env.PUSHER_APP_ENCRYPTED, + disableStats: process.env.PUSHER_APP_DISABLE_STATS, + enabledTransports: ['ws', 'wss'], + }, }, }, }) diff --git a/nuxt/components/book-recommendations/BookRecommendationTable.vue b/nuxt/components/book-recommendations/BookRecommendationTable.vue index 016db2c..1220c2f 100644 --- a/nuxt/components/book-recommendations/BookRecommendationTable.vue +++ b/nuxt/components/book-recommendations/BookRecommendationTable.vue @@ -6,6 +6,8 @@ import NewBookRecommendation from '~/components/modal/NewBookRecommendation.vue' import CastVote from '~/components/modal/CastVote.vue' const dayjs = useDayjs() +const { $echo } = useNuxtApp() +const authStore = useAuthStore() const bookRecommendationStore = useBookRecommendationStore() bookRecommendationStore.fetchRecommendations() @@ -68,6 +70,20 @@ const sort = ref({ function resolveStatus(status: string) { return bookRecommendationStore.statusOptions.find(option => option.value === status) } + +onMounted(() => { + $echo.private(`BookRecommendation`) + .listen('.BookRecommendationUpdated', (e) => { + bookRecommendationStore.updateRecommendationWS(e.bookRecommendation) + }) + .listen('.BookRecommendationDeleted', (e) => { + bookRecommendationStore.deleteRecommendationWS(e.bookRecommendation) + }) + .listen('.BookRecommendationCreated', (e) => { + bookRecommendationStore.createRecommendationWS(e.bookRecommendation) + }) + authStore.socketId = $echo.socketId() +})