From 97aaaf1b8553024914db484cf20f9294465d2de2 Mon Sep 17 00:00:00 2001 From: red Date: Fri, 5 Dec 2025 10:11:21 +0000 Subject: [PATCH] withdraw --- app/Models/Participant.php | 11 +- composer.json | 5 +- composer.lock | 298 ++++++++++++++- need | 3 - .../views/livewire/pages/profile.blade.php | 17 +- .../views/livewire/pages/withdraw.blade.php | 350 ++++++++++++++++++ routes/web.php | 2 +- 7 files changed, 669 insertions(+), 17 deletions(-) delete mode 100644 need diff --git a/app/Models/Participant.php b/app/Models/Participant.php index 321ba6e..c31f1f3 100644 --- a/app/Models/Participant.php +++ b/app/Models/Participant.php @@ -4,6 +4,8 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Support\Facades\Log; class Participant extends Model @@ -20,12 +22,12 @@ class Participant extends Model protected $appends = ['desperate']; - public function receiver() + public function receiver() : belongsTo { return $this->belongsTo(Participant::class, 'giving_id'); } - public function giver() + public function giver(): hasOne { return $this->hasOne(Participant::class, 'giving_id', 'id'); } @@ -75,5 +77,8 @@ class Participant extends Model return ($gives && !$gets) || (!$gives && $gets); } - + public function withdraw(): bool + { + return false; + } } diff --git a/composer.json b/composer.json index 0070991..81acf75 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,8 @@ "ext-curl": "*" }, "require-dev": { + "ext-curl": "*", + "barryvdh/laravel-ide-helper": "^3.6", "fakerphp/faker": "^1.23", "laravel/pail": "^1.2.2", "laravel/pint": "^1.24", @@ -25,8 +27,7 @@ "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.6", "pestphp/pest": "^4.1", - "pestphp/pest-plugin-laravel": "^4.0", - "ext-curl": "*" + "pestphp/pest-plugin-laravel": "^4.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 43a3447..da42240 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": "c78bcab45d4b86c31ecc79b40f1a12ad", + "content-hash": "10384b5e2e1414abcd436d205f0114a6", "packages": [ { "name": "bacon/bacon-qr-code", @@ -6496,6 +6496,152 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-ide-helper", + "version": "v3.6.0", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-ide-helper.git", + "reference": "8d00250cba25728373e92c1d8dcebcbf64623d29" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/8d00250cba25728373e92c1d8dcebcbf64623d29", + "reference": "8d00250cba25728373e92c1d8dcebcbf64623d29", + "shasum": "" + }, + "require": { + "barryvdh/reflection-docblock": "^2.4", + "composer/class-map-generator": "^1.0", + "ext-json": "*", + "illuminate/console": "^11.15 || ^12", + "illuminate/database": "^11.15 || ^12", + "illuminate/filesystem": "^11.15 || ^12", + "illuminate/support": "^11.15 || ^12", + "php": "^8.2" + }, + "require-dev": { + "ext-pdo_sqlite": "*", + "friendsofphp/php-cs-fixer": "^3", + "illuminate/config": "^11.15 || ^12", + "illuminate/view": "^11.15 || ^12", + "mockery/mockery": "^1.4", + "orchestra/testbench": "^9.2 || ^10", + "phpunit/phpunit": "^10.5 || ^11.5.3", + "spatie/phpunit-snapshot-assertions": "^4 || ^5", + "vimeo/psalm": "^5.4", + "vlucas/phpdotenv": "^5" + }, + "suggest": { + "illuminate/events": "Required for automatic helper generation (^6|^7|^8|^9|^10|^11)." + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Barryvdh\\LaravelIdeHelper\\IdeHelperServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "3.5-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\LaravelIdeHelper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.", + "keywords": [ + "autocomplete", + "codeintel", + "dev", + "helper", + "ide", + "laravel", + "netbeans", + "phpdoc", + "phpstorm", + "sublime" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-ide-helper/issues", + "source": "https://github.com/barryvdh/laravel-ide-helper/tree/v3.6.0" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2025-07-17T20:11:57+00:00" + }, + { + "name": "barryvdh/reflection-docblock", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/ReflectionDocBlock.git", + "reference": "d103774cbe7e94ddee7e4870f97f727b43fe7201" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/ReflectionDocBlock/zipball/d103774cbe7e94ddee7e4870f97f727b43fe7201", + "reference": "d103774cbe7e94ddee7e4870f97f727b43fe7201", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.14|^9" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Barryvdh": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "support": { + "source": "https://github.com/barryvdh/ReflectionDocBlock/tree/v2.4.0" + }, + "time": "2025-07-17T06:07:30+00:00" + }, { "name": "brianium/paratest", "version": "v7.15.0", @@ -6589,6 +6735,154 @@ ], "time": "2025-11-30T08:08:11+00:00" }, + { + "name": "composer/class-map-generator", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/composer/class-map-generator.git", + "reference": "2373419b7709815ed323ebf18c3c72d03ff4a8a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/2373419b7709815ed323ebf18c3c72d03ff4a8a6", + "reference": "2373419b7709815ed323ebf18c3c72d03ff4a8a6", + "shasum": "" + }, + "require": { + "composer/pcre": "^2.1 || ^3.1", + "php": "^7.2 || ^8.0", + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7 || ^8" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-deprecation-rules": "^1 || ^2", + "phpstan/phpstan-phpunit": "^1 || ^2", + "phpstan/phpstan-strict-rules": "^1.1 || ^2", + "phpunit/phpunit": "^8", + "symfony/filesystem": "^5.4 || ^6 || ^7 || ^8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\ClassMapGenerator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Utilities to scan PHP code and generate class maps.", + "keywords": [ + "classmap" + ], + "support": { + "issues": "https://github.com/composer/class-map-generator/issues", + "source": "https://github.com/composer/class-map-generator/tree/1.7.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + } + ], + "time": "2025-11-19T10:41:15+00:00" + }, + { + "name": "composer/pcre", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-11-12T16:29:46+00:00" + }, { "name": "doctrine/deprecations", "version": "1.1.5", @@ -9840,5 +10134,5 @@ "platform-dev": { "ext-curl": "*" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.9.0" } diff --git a/need b/need deleted file mode 100644 index 3d35e14..0000000 --- a/need +++ /dev/null @@ -1,3 +0,0 @@ -bot gens api token -api token with link to access the page - diff --git a/resources/views/livewire/pages/profile.blade.php b/resources/views/livewire/pages/profile.blade.php index 0895ac5..8fb564b 100644 --- a/resources/views/livewire/pages/profile.blade.php +++ b/resources/views/livewire/pages/profile.blade.php @@ -27,7 +27,8 @@ rules([ ], ]); -mount(function ($token) { +mount(function ($token): null +{ $this->token = $token; if ($this->token) { $this->participant = Participant::findByToken($this->token); @@ -50,7 +51,8 @@ mount(function ($token) { } }); -$saveEditingPrompt = function () { +$saveEditingPrompt = function (): null +{ if ($this->participant) { $this->validate(); @@ -60,12 +62,14 @@ $saveEditingPrompt = function () { } }; -$cancelEditingPrompt = function () { +$cancelEditingPrompt = function (): null +{ $this->prompt = $this->participant->prompt ?? ''; $this->isEditingPrompt = false; }; -$saveEditingSubmission = function () { +$saveEditingSubmission = function (): null +{ if ($this->participant) { $this->validate(); @@ -75,7 +79,8 @@ $saveEditingSubmission = function () { } }; -$cancelEditingSubmission = function () { +$cancelEditingSubmission = function (): null +{ $this->submissionUrl = $this->participant->submission_url ?? ''; $this->isEditingSubmission = false; }; @@ -206,7 +211,7 @@ $cancelEditingSubmission = function () { @endif Withdraw from Secret Sketchers... diff --git a/resources/views/livewire/pages/withdraw.blade.php b/resources/views/livewire/pages/withdraw.blade.php index b3d9bbc..cce8eff 100644 --- a/resources/views/livewire/pages/withdraw.blade.php +++ b/resources/views/livewire/pages/withdraw.blade.php @@ -1 +1,351 @@ null, +]); + +mount(function ($token): null +{ + $this->token = $token; + if ($this->token) { + $this->participant = Participant::findByToken($this->token); + } +}); + +$confirmWithdrawal = function (): null +{ + $this->js(<<<'JS' + if (confirm('Are you sure you want to withdraw from the event? This action cannot be undone.')) { + $wire.call('withdraw'); + } + JS); +}; + +$withdraw = function (): mixed +{ + if($this->participant->withdraw()) { + $this->js('alert("Withdrawal complete")'); + return $this->redirect('/', navigate: true); + } + else { + $this->js('alert("Something went wrong")'); + return null; + } +}; + +?> + +
+

Withdraw from the event?

+ + + +
diff --git a/routes/web.php b/routes/web.php index 61f5422..dd3f306 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,4 +10,4 @@ Route::get('/', function () { Volt::route('start', 'pages.start')->name('start'); Volt::route('table', 'pages.table')->name('table'); Volt::route('profile/{token}', 'pages.profile')->name('profile'); -Volt::route('withdraw', 'pages.withdraw')->name('withdraw'); +Volt::route('withdraw/{token}', 'pages.withdraw')->name('withdraw');