diff --git a/app/Http/Livewire/Tables/BookCaseTable.php b/app/Http/Livewire/Tables/BookCaseTable.php index 0b337fd0..c4877db1 100644 --- a/app/Http/Livewire/Tables/BookCaseTable.php +++ b/app/Http/Livewire/Tables/BookCaseTable.php @@ -137,7 +137,7 @@ class BookCaseTable extends DataTableComponent 'date' => $this->orangepill['date'], ]); if ($this->orangepill['comment']) { - $this->currentModal->comment($this->orangepill['comment']); + $this->currentModal->comment($this->orangepill['comment'], null); } $this->resetModal(); $this->emit('refreshDatatable'); diff --git a/app/Models/BookCase.php b/app/Models/BookCase.php index 307f5163..0a075733 100644 --- a/app/Models/BookCase.php +++ b/app/Models/BookCase.php @@ -7,7 +7,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; +use Spatie\Comments\Exceptions\CannotCreateComment; +use Spatie\Comments\Models\Comment; use Spatie\Comments\Models\Concerns\HasComments; +use Spatie\Comments\Models\Concerns\Interfaces\CanComment; +use Spatie\Comments\Support\Config; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -91,4 +95,36 @@ class BookCase extends Model implements HasMedia { return url()->route('bookCases.comment.bookcase', ['bookCase' => $this->id]); } + + public function comment(string $text, CanComment $commentator = null): Comment + { + // $commentator ??= auth()->user(); + + if (! config('comments.allow_anonymous_comments')) { + if (! $commentator) { + throw CannotCreateComment::userIsRequired(); + } + } + + $parentId = ($this::class === Config::getCommentModelName()) + ? $this->getKey() + : null; + + $comment = $this->comments()->create([ + 'commentator_id' => $commentator?->getKey() ?? null, + 'commentator_type' => $commentator?->getMorphClass() ?? null, + 'original_text' => $text, + 'parent_id' => $parentId, + ]); + + if ($comment->shouldBeAutomaticallyApproved()) { + Config::approveCommentAction()->execute($comment); + + return $comment; + } + + Config::sendNotificationsForPendingCommentAction()->execute($comment); + + return $comment; + } } diff --git a/composer.lock b/composer.lock index ef86cdc9..78e477e4 100644 --- a/composer.lock +++ b/composer.lock @@ -688,16 +688,16 @@ }, { "name": "doctrine/dbal", - "version": "3.5.1", + "version": "3.5.2", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "f38ee8aaca2d58ee88653cb34a6a3880c23f38a5" + "reference": "63e513cebbbaf96a6795e5c5ee34d205831bfc85" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/f38ee8aaca2d58ee88653cb34a6a3880c23f38a5", - "reference": "f38ee8aaca2d58ee88653cb34a6a3880c23f38a5", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/63e513cebbbaf96a6795e5c5ee34d205831bfc85", + "reference": "63e513cebbbaf96a6795e5c5ee34d205831bfc85", "shasum": "" }, "require": { @@ -710,16 +710,16 @@ "psr/log": "^1|^2|^3" }, "require-dev": { - "doctrine/coding-standard": "10.0.0", - "jetbrains/phpstorm-stubs": "2022.2", - "phpstan/phpstan": "1.8.10", + "doctrine/coding-standard": "11.0.0", + "jetbrains/phpstorm-stubs": "2022.3", + "phpstan/phpstan": "1.9.2", "phpstan/phpstan-strict-rules": "^1.4", - "phpunit/phpunit": "9.5.25", - "psalm/plugin-phpunit": "0.17.0", + "phpunit/phpunit": "9.5.27", + "psalm/plugin-phpunit": "0.18.4", "squizlabs/php_codesniffer": "3.7.1", "symfony/cache": "^5.4|^6.0", "symfony/console": "^4.4|^5.4|^6.0", - "vimeo/psalm": "4.29.0" + "vimeo/psalm": "4.30.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -779,7 +779,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.5.1" + "source": "https://github.com/doctrine/dbal/tree/3.5.2" }, "funding": [ { @@ -795,7 +795,7 @@ "type": "tidelift" } ], - "time": "2022-10-24T07:26:18+00:00" + "time": "2022-12-19T08:17:34+00:00" }, { "name": "doctrine/deprecations", @@ -2642,16 +2642,16 @@ }, { "name": "laravel/framework", - "version": "v9.44.0", + "version": "v9.45.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "60808a7d9acd53461fd69634c08fc7e0a99fbf98" + "reference": "f2c51fdfcb0c50c19cdc49c2e82690ad1a21eafe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/60808a7d9acd53461fd69634c08fc7e0a99fbf98", - "reference": "60808a7d9acd53461fd69634c08fc7e0a99fbf98", + "url": "https://api.github.com/repos/laravel/framework/zipball/f2c51fdfcb0c50c19cdc49c2e82690ad1a21eafe", + "reference": "f2c51fdfcb0c50c19cdc49c2e82690ad1a21eafe", "shasum": "" }, "require": { @@ -2662,7 +2662,7 @@ "ext-openssl": "*", "fruitcake/php-cors": "^1.2", "laravel/serializable-closure": "^1.2.2", - "league/commonmark": "^2.2", + "league/commonmark": "^2.2.1", "league/flysystem": "^3.8.0", "monolog/monolog": "^2.0", "nesbot/carbon": "^2.62.1", @@ -2671,7 +2671,7 @@ "psr/container": "^1.1.1|^2.0.1", "psr/log": "^1.0|^2.0|^3.0", "psr/simple-cache": "^1.0|^2.0|^3.0", - "ramsey/uuid": "^4.2.2", + "ramsey/uuid": "^4.7", "symfony/console": "^6.0.9", "symfony/error-handler": "^6.0", "symfony/finder": "^6.0", @@ -2732,7 +2732,7 @@ "ably/ably-php": "^1.0", "aws/aws-sdk-php": "^3.235.5", "doctrine/dbal": "^2.13.3|^3.1.4", - "fakerphp/faker": "^1.9.2", + "fakerphp/faker": "^1.21", "guzzlehttp/guzzle": "^7.5", "league/flysystem-aws-s3-v3": "^3.0", "league/flysystem-ftp": "^3.0", @@ -2740,7 +2740,7 @@ "league/flysystem-read-only": "^3.3", "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.5.1", - "orchestra/testbench-core": "^7.11", + "orchestra/testbench-core": "^7.16", "pda/pheanstalk": "^4.0", "phpstan/phpstan": "^1.4.7", "phpunit/phpunit": "^9.5.8", @@ -2824,20 +2824,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-12-15T14:56:36+00:00" + "time": "2022-12-20T14:16:06+00:00" }, { "name": "laravel/jetstream", - "version": "v2.13.0", + "version": "v2.13.1", "source": { "type": "git", "url": "https://github.com/laravel/jetstream.git", - "reference": "790559c879bfcf3f51df87ba274211e741d6683e" + "reference": "8e241881c123f96c55fb7cddfb63408958427919" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/jetstream/zipball/790559c879bfcf3f51df87ba274211e741d6683e", - "reference": "790559c879bfcf3f51df87ba274211e741d6683e", + "url": "https://api.github.com/repos/laravel/jetstream/zipball/8e241881c123f96c55fb7cddfb63408958427919", + "reference": "8e241881c123f96c55fb7cddfb63408958427919", "shasum": "" }, "require": { @@ -2894,7 +2894,7 @@ "issues": "https://github.com/laravel/jetstream/issues", "source": "https://github.com/laravel/jetstream" }, - "time": "2022-12-15T14:58:38+00:00" + "time": "2022-12-16T16:44:02+00:00" }, { "name": "laravel/legacy-factories", @@ -3507,16 +3507,16 @@ }, { "name": "league/flysystem", - "version": "3.11.0", + "version": "3.12.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "7e423e5dd240a60adfab9bde058d7668863b7731" + "reference": "2aef65a47e44f2d6f9938f720f6dd697e7ba7b76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/7e423e5dd240a60adfab9bde058d7668863b7731", - "reference": "7e423e5dd240a60adfab9bde058d7668863b7731", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/2aef65a47e44f2d6f9938f720f6dd697e7ba7b76", + "reference": "2aef65a47e44f2d6f9938f720f6dd697e7ba7b76", "shasum": "" }, "require": { @@ -3578,7 +3578,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.11.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.12.0" }, "funding": [ { @@ -3594,7 +3594,7 @@ "type": "tidelift" } ], - "time": "2022-12-02T14:39:57+00:00" + "time": "2022-12-20T20:21:10+00:00" }, { "name": "league/glide", @@ -4869,16 +4869,16 @@ }, { "name": "nunomaduro/termwind", - "version": "v1.14.2", + "version": "v1.15.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/termwind.git", - "reference": "9a8218511eb1a0965629ff820dda25985440aefc" + "reference": "594ab862396c16ead000de0c3c38f4a5cbe1938d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/9a8218511eb1a0965629ff820dda25985440aefc", - "reference": "9a8218511eb1a0965629ff820dda25985440aefc", + "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/594ab862396c16ead000de0c3c38f4a5cbe1938d", + "reference": "594ab862396c16ead000de0c3c38f4a5cbe1938d", "shasum": "" }, "require": { @@ -4935,7 +4935,7 @@ ], "support": { "issues": "https://github.com/nunomaduro/termwind/issues", - "source": "https://github.com/nunomaduro/termwind/tree/v1.14.2" + "source": "https://github.com/nunomaduro/termwind/tree/v1.15.0" }, "funding": [ { @@ -4951,7 +4951,7 @@ "type": "github" } ], - "time": "2022-10-28T22:51:32+00:00" + "time": "2022-12-20T19:00:15+00:00" }, { "name": "nyholm/psr7", @@ -6010,16 +6010,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.21", + "version": "9.2.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0" + "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3f893e19712bb0c8bc86665d1562e9fd509c4ef0", - "reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e4bf60d2220b4baaa0572986b5d69870226b06df", + "reference": "e4bf60d2220b4baaa0572986b5d69870226b06df", "shasum": "" }, "require": { @@ -6075,7 +6075,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.21" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.22" }, "funding": [ { @@ -6083,7 +6083,7 @@ "type": "github" } ], - "time": "2022-12-14T13:26:54+00:00" + "time": "2022-12-18T16:40:55+00:00" }, { "name": "phpunit/php-file-iterator", @@ -7388,23 +7388,23 @@ }, { "name": "ramsey/uuid", - "version": "4.6.0", + "version": "4.7.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f" + "reference": "5ed9ad582647bbc3864ef78db34bdc1afdcf9b49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/ad63bc700e7d021039e30ce464eba384c4a1d40f", - "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/5ed9ad582647bbc3864ef78db34bdc1afdcf9b49", + "reference": "5ed9ad582647bbc3864ef78db34bdc1afdcf9b49", "shasum": "" }, "require": { "brick/math": "^0.8.8 || ^0.9 || ^0.10", "ext-json": "*", "php": "^8.0", - "ramsey/collection": "^1.0" + "ramsey/collection": "^1.2" }, "replace": { "rhumsaa/uuid": "self.version" @@ -7464,7 +7464,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.6.0" + "source": "https://github.com/ramsey/uuid/tree/4.7.0" }, "funding": [ { @@ -7476,7 +7476,7 @@ "type": "tidelift" } ], - "time": "2022-11-05T23:03:38+00:00" + "time": "2022-12-19T22:30:49+00:00" }, { "name": "rap2hpoutre/fast-excel", @@ -9608,17 +9608,17 @@ }, { "name": "spatie/laravel-comments-livewire", - "version": "1.2.8", + "version": "1.2.9", "source": { "type": "git", "url": "git@github.com:spatie/laravel-comments-livewire.git", - "reference": "ac34fbb12bb1f3c8cecf1caef1d0372ad0410d09" + "reference": "ef4bac8dcf5ae76c30f851258100c122e167b31b" }, "dist": { "type": "zip", - "url": "https://satis.spatie.be/dist/spatie/laravel-comments-livewire/spatie-laravel-comments-livewire-ac34fbb12bb1f3c8cecf1caef1d0372ad0410d09-zip-03d069.zip", - "reference": "ac34fbb12bb1f3c8cecf1caef1d0372ad0410d09", - "shasum": "039266a75856ba8c7eab0844c68fffb996d0dff0" + "url": "https://satis.spatie.be/dist/spatie/laravel-comments-livewire/spatie-laravel-comments-livewire-ef4bac8dcf5ae76c30f851258100c122e167b31b-zip-c07850.zip", + "reference": "ef4bac8dcf5ae76c30f851258100c122e167b31b", + "shasum": "840d41ef67fd55e33a88ff9f33be361b3413d174" }, "require": { "illuminate/contracts": "^9.0", @@ -9688,7 +9688,7 @@ "spatie" ], "support": { - "source": "https://github.com/spatie/laravel-comments-livewire/tree/1.2.8" + "source": "https://github.com/spatie/laravel-comments-livewire/tree/1.2.9" }, "funding": [ { @@ -9696,7 +9696,7 @@ "url": "https://github.com/spatie" } ], - "time": "2022-10-17T07:19:57+00:00" + "time": "2022-12-20T15:05:46+00:00" }, { "name": "spatie/laravel-google-fonts", @@ -10106,16 +10106,16 @@ }, { "name": "spatie/laravel-package-tools", - "version": "1.13.7", + "version": "1.13.8", "source": { "type": "git", "url": "https://github.com/spatie/laravel-package-tools.git", - "reference": "4af8e608184471b5568af6265ebb0ca0025c131a" + "reference": "781a2f637237e69c277eb401063acf15e2b4156b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/4af8e608184471b5568af6265ebb0ca0025c131a", - "reference": "4af8e608184471b5568af6265ebb0ca0025c131a", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/781a2f637237e69c277eb401063acf15e2b4156b", + "reference": "781a2f637237e69c277eb401063acf15e2b4156b", "shasum": "" }, "require": { @@ -10154,7 +10154,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-package-tools/issues", - "source": "https://github.com/spatie/laravel-package-tools/tree/1.13.7" + "source": "https://github.com/spatie/laravel-package-tools/tree/1.13.8" }, "funding": [ { @@ -10162,7 +10162,7 @@ "type": "github" } ], - "time": "2022-11-15T09:10:09+00:00" + "time": "2022-12-20T14:09:05+00:00" }, { "name": "spatie/laravel-permission", @@ -15460,16 +15460,16 @@ }, { "name": "laravel-lang/lang", - "version": "12.7.3", + "version": "12.8.1", "source": { "type": "git", "url": "https://github.com/Laravel-Lang/lang.git", - "reference": "28e1941e8799b48ee1fdcf64137e64fdfffc763e" + "reference": "67291c7b53f4c94f070e7a23ae831012a4879f1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Laravel-Lang/lang/zipball/28e1941e8799b48ee1fdcf64137e64fdfffc763e", - "reference": "28e1941e8799b48ee1fdcf64137e64fdfffc763e", + "url": "https://api.github.com/repos/Laravel-Lang/lang/zipball/67291c7b53f4c94f070e7a23ae831012a4879f1d", + "reference": "67291c7b53f4c94f070e7a23ae831012a4879f1d", "shasum": "" }, "require": { @@ -15531,7 +15531,7 @@ "type": "open_collective" } ], - "time": "2022-12-16T20:43:31+00:00" + "time": "2022-12-21T10:17:06+00:00" }, { "name": "laravel-lang/publisher", @@ -15739,16 +15739,16 @@ }, { "name": "laravel/pint", - "version": "v1.2.1", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1" + "reference": "6a2c0927b4f6ad4eadb5a67fe3835fdad108949d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/e60e2112ee779ce60f253695b273d1646a17d6f1", - "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1", + "url": "https://api.github.com/repos/laravel/pint/zipball/6a2c0927b4f6ad4eadb5a67fe3835fdad108949d", + "reference": "6a2c0927b4f6ad4eadb5a67fe3835fdad108949d", "shasum": "" }, "require": { @@ -15759,7 +15759,7 @@ "php": "^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.11.0", + "friendsofphp/php-cs-fixer": "~3.13.1", "illuminate/view": "^9.32.0", "laravel-zero/framework": "^9.2.0", "mockery/mockery": "^1.5.1", @@ -15801,20 +15801,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2022-11-29T16:25:20+00:00" + "time": "2022-12-20T17:16:15+00:00" }, { "name": "laravel/sail", - "version": "v1.16.5", + "version": "v1.16.6", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "9ec5338d13bdc941a23347cb36385988c525fe02" + "reference": "2e8be54590bde421eb04e461a1421302a5b22cca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/9ec5338d13bdc941a23347cb36385988c525fe02", - "reference": "9ec5338d13bdc941a23347cb36385988c525fe02", + "url": "https://api.github.com/repos/laravel/sail/zipball/2e8be54590bde421eb04e461a1421302a5b22cca", + "reference": "2e8be54590bde421eb04e461a1421302a5b22cca", "shasum": "" }, "require": { @@ -15861,7 +15861,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2022-12-14T14:54:21+00:00" + "time": "2022-12-19T15:41:32+00:00" }, { "name": "mockery/mockery", diff --git a/config/comments.php b/config/comments.php index 4308fca9..a8199f7a 100644 --- a/config/comments.php +++ b/config/comments.php @@ -24,7 +24,7 @@ return [ * You can allow guests to post comments. They will not be able to use * reactions. */ - 'allow_anonymous_comments' => false, + 'allow_anonymous_comments' => true, /* * A comment transformer is a class that will transform the comment text @@ -82,7 +82,7 @@ return [ * When somebody creates a comment, a notification will be sent to other persons * that commented on the same thing. */ - 'enabled' => true, + 'enabled' => false, 'notifications' => [ 'pending_comment' => PendingCommentNotification::class, diff --git a/config/ignition.php b/config/ignition.php index 596fd613..bfdb991e 100644 --- a/config/ignition.php +++ b/config/ignition.php @@ -176,7 +176,7 @@ return [ */ 'remote_sites_path' => env('IGNITION_REMOTE_SITES_PATH', '/var/www/html'), - 'local_sites_path' => env('IGNITION_LOCAL_SITES_PATH', '/home/fsociety/Code/side/einundzwanzig-bitcoin-school'), + 'local_sites_path' => env('IGNITION_LOCAL_SITES_PATH', '/home/fsociety/Code/side/einundzwanzig-portal'), /* |-------------------------------------------------------------------------- diff --git a/config/translation.php b/config/translation.php index 223fb2db..dc3a702b 100644 --- a/config/translation.php +++ b/config/translation.php @@ -11,7 +11,7 @@ return [ | Supported: "file", "database" | */ - 'driver' => 'database', + 'driver' => env('TRANSLATION_DRIVER', 'file'), /* |-------------------------------------------------------------------------- diff --git a/ray.php b/ray.php index 81cddee9..ee3c7669 100644 --- a/ray.php +++ b/ray.php @@ -99,7 +99,7 @@ return [ * Absolute base path for your sites or projects on your local * computer where your IDE or code editor is running on. */ - 'local_path' => env('RAY_LOCAL_PATH', '/home/fsociety/Code/side/einundzwanzig-bitcoin-school'), + 'local_path' => env('RAY_LOCAL_PATH', '/home/fsociety/Code/side/einundzwanzig-portal'), /* * When this setting is enabled, the package will not try to format values sent to Ray. diff --git a/resources/views/livewire/book-case/book-case-table.blade.php b/resources/views/livewire/book-case/book-case-table.blade.php index a449141c..9e5998f0 100644 --- a/resources/views/livewire/book-case/book-case-table.blade.php +++ b/resources/views/livewire/book-case/book-case-table.blade.php @@ -18,12 +18,17 @@