Rename Events to Giveaways

This commit is contained in:
Jay Sizzla
2025-11-29 11:16:36 +00:00
parent 9618870cc6
commit 6546c3b999
26 changed files with 404 additions and 347 deletions
@@ -16,32 +16,32 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Models\ClaimedPrize;
use App\Models\Event;
use App\Models\GiveawayClaimedPrize;
use App\Models\Giveaway;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ClaimedPrizeController extends Controller
class GiveawayClaimedPrizeController extends Controller
{
/**
* Store a newly created resource in storage.
*/
public function store(Request $request, Event $event): \Illuminate\Http\RedirectResponse
public function store(Request $request, Giveaway $giveaway): \Illuminate\Http\RedirectResponse
{
if (!$event->active) {
return back()->withErrors('Event is not active.');
if (!$giveaway->active) {
return back()->withErrors('Giveaway is not active.');
}
$isAvailable = now()->isBetween($event->starts_at->startOfDay(), $event->ends_at->endOfDay());
$isAvailable = now()->isBetween($giveaway->starts_at->startOfDay(), $giveaway->ends_at->endOfDay());
if (!$isAvailable) {
return back()->withErrors('Prizes are not currently available.');
}
return DB::transaction(function () use ($request, $event) {
$prizeExists = ClaimedPrize::query()
return DB::transaction(function () use ($request, $giveaway) {
$prizeExists = GiveawayClaimedPrize::query()
->whereBelongsTo($request->user())
->whereBelongsTo($event)
->whereBelongsTo($giveaway)
->where('created_at', '>', now()->startOfDay())
->exists();
@@ -49,7 +49,7 @@ class ClaimedPrizeController extends Controller
return back()->withErrors('You have already claimed your daily prize. Check back tomorrow!');
}
$prizes = $event->prizes;
$prizes = $giveaway->prizes;
$randomNumber = random_int(1, $prizes->sum('weight') ?: 1);
$selectedPrize = null;
@@ -79,14 +79,14 @@ class ClaimedPrizeController extends Controller
break;
}
ClaimedPrize::create([
'user_id' => $request->user()->id,
'event_id' => $event->id,
'bon' => $bon_won,
'fl_tokens' => $fl_tokens_won,
GiveawayClaimedPrize::create([
'user_id' => $request->user()->id,
'giveaway_id' => $giveaway->id,
'bon' => $bon_won,
'fl_tokens' => $fl_tokens_won,
]);
return to_route('events.show', ['event' => $event])->with('success', 'Congrats! You have won a prize!');
return to_route('giveaways.show', ['giveaway' => $giveaway])->with('success', 'Congrats! You have won a prize!');
});
}
}
@@ -16,33 +16,33 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Models\Event;
use App\Models\Giveaway;
use Illuminate\Http\Request;
class EventController extends Controller
class GiveawayController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('event.index', [
'events' => Event::query()->where('active', '=', true)->orderBy('starts_at')->get(),
return view('giveaway.index', [
'giveaways' => Giveaway::query()->where('active', '=', true)->orderBy('starts_at')->get(),
]);
}
/**
* Display the specified resource.
*/
public function show(Request $request, Event $event): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
public function show(Request $request, Giveaway $giveaway): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('event.show', [
'event' => $event,
'userPrizes' => $event
return view('giveaway.show', [
'giveaway' => $giveaway,
'userPrizes' => $giveaway
->claimedPrizes()
->where('user_id', '=', $request->user()->id)
->get()
->groupBy(fn ($claimedPrize) => (int) $claimedPrize->created_at->diffInDays($event->starts_at, true)),
->groupBy(fn ($claimedPrize) => (int) $claimedPrize->created_at->diffInDays($giveaway->starts_at, true)),
]);
}
}
@@ -1,76 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Staff;
use App\Http\Controllers\Controller;
use App\Http\Requests\Staff\StoreEventRequest;
use App\Http\Requests\Staff\UpdateEventRequest;
use App\Models\Event;
class EventController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('Staff.event.index', [
'events' => Event::all(),
]);
}
/**
* Show the form for creating a new resource.
*/
public function create(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('Staff.event.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreEventRequest $request): \Illuminate\Http\RedirectResponse
{
Event::create($request->validated());
return to_route('staff.events.index');
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Event $event): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('Staff.event.edit', [
'event' => $event->load('prizes'),
]);
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateEventRequest $request, Event $event): \Illuminate\Http\RedirectResponse
{
$event->update($request->validated());
return to_route('staff.events.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Event $event): \Illuminate\Http\RedirectResponse
{
if ($event->claimedPrizes()->exists()) {
return to_route('staff.events.index')
->withErrors('Cannot delete event because users have claimed prizes. You can mark it as inactive instead.');
}
$event->delete();
return to_route('staff.events.index');
}
}
@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Staff;
use App\Http\Controllers\Controller;
use App\Http\Requests\Staff\StoreGiveawayRequest;
use App\Http\Requests\Staff\UpdateGiveawayRequest;
use App\Models\Giveaway;
class GiveawayController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('Staff.giveaway.index', [
'giveaways' => Giveaway::all(),
]);
}
/**
* Show the form for creating a new resource.
*/
public function create(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('Staff.giveaway.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreGiveawayRequest $request): \Illuminate\Http\RedirectResponse
{
Giveaway::create($request->validated());
return to_route('staff.giveaways.index');
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Giveaway $giveaway): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return view('Staff.giveaway.edit', [
'giveaway' => $giveaway->load('prizes'),
]);
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateGiveawayRequest $request, Giveaway $giveaway): \Illuminate\Http\RedirectResponse
{
$giveaway->update($request->validated());
return to_route('staff.giveaways.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Giveaway $giveaway): \Illuminate\Http\RedirectResponse
{
if ($giveaway->claimedPrizes()->exists()) {
return to_route('staff.giveaways.index')
->withErrors('Cannot delete giveaway because users have claimed prizes. You can mark it as inactive instead.');
}
$giveaway->delete();
return to_route('staff.giveaways.index');
}
}
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Roardom <roardom@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Http\Controllers\Staff;
use App\Http\Controllers\Controller;
use App\Http\Requests\Staff\StoreGiveawayPrizeRequest;
use App\Http\Requests\Staff\UpdateGiveawayPrizeRequest;
use App\Models\Giveaway;
use App\Models\GiveawayPrize;
class GiveawayPrizeController extends Controller
{
/**
* Store a newly created resource in storage.
*/
public function store(StoreGiveawayPrizeRequest $request, Giveaway $giveaway): \Illuminate\Http\RedirectResponse
{
$giveaway->prizes()->create($request->validated());
return to_route('staff.giveaways.edit', [
'giveaway' => $giveaway
])
->with('success', 'Prize added to giveaway.');
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateGiveawayPrizeRequest $request, Giveaway $giveaway, GiveawayPrize $prize): \Illuminate\Http\RedirectResponse
{
$prize->update($request->validated());
return to_route('staff.giveaways.edit', [
'giveaway' => $giveaway
])
->with('success', 'Prize updated.');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Giveaway $giveaway, GiveawayPrize $prize): \Illuminate\Http\RedirectResponse
{
$prize->delete();
return to_route('staff.giveaways.edit', [
'giveaway' => $giveaway
])
->with('success', 'Prize removed from giveaway.');
}
}
@@ -1,65 +0,0 @@
<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Roardom <roardom@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Http\Controllers\Staff;
use App\Http\Controllers\Controller;
use App\Http\Requests\Staff\StorePrizeRequest;
use App\Http\Requests\Staff\UpdatePrizeRequest;
use App\Models\Event;
use App\Models\Prize;
class PrizeController extends Controller
{
/**
* Store a newly created resource in storage.
*/
public function store(StorePrizeRequest $request, Event $event): \Illuminate\Http\RedirectResponse
{
$event->prizes()->create($request->validated());
return to_route('staff.events.edit', [
'event' => $event
])
->with('success', 'Prize added to event.');
}
/**
* Update the specified resource in storage.
*/
public function update(UpdatePrizeRequest $request, Event $event, Prize $prize): \Illuminate\Http\RedirectResponse
{
$prize->update($request->validated());
return to_route('staff.events.edit', [
'event' => $event
])
->with('success', 'Prize updated.');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Event $event, Prize $prize): \Illuminate\Http\RedirectResponse
{
$prize->delete();
return to_route('staff.events.edit', [
'event' => $event
])
->with('success', 'Prize removed from event.');
}
}
@@ -18,7 +18,7 @@ namespace App\Http\Requests\Staff;
use Illuminate\Foundation\Http\FormRequest;
class UpdatePrizeRequest extends FormRequest
class StoreGiveawayPrizeRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
@@ -18,7 +18,7 @@ namespace App\Http\Requests\Staff;
use Illuminate\Foundation\Http\FormRequest;
class StoreEventRequest extends FormRequest
class StoreGiveawayRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
@@ -18,7 +18,7 @@ namespace App\Http\Requests\Staff;
use Illuminate\Foundation\Http\FormRequest;
class StorePrizeRequest extends FormRequest
class UpdateGiveawayPrizeRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
@@ -18,7 +18,7 @@ namespace App\Http\Requests\Staff;
use Illuminate\Foundation\Http\FormRequest;
class UpdateEventRequest extends FormRequest
class UpdateGiveawayRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
@@ -34,7 +34,7 @@ use AllowDynamicProperties;
* @property \Illuminate\Support\Carbon|null $updated_at
*/
#[AllowDynamicProperties]
final class Event extends Model
final class Giveaway extends Model
{
use Auditable;
@@ -61,20 +61,20 @@ final class Event extends Model
/**
* Get the claimed prizes for the event.
*
* @return HasMany<ClaimedPrize, $this>
* @return HasMany<GiveawayClaimedPrize, $this>
*/
public function claimedPrizes(): HasMany
{
return $this->hasMany(ClaimedPrize::class);
return $this->hasMany(GiveawayClaimedPrize::class);
}
/**
* Get the available prizes for the event.
*
* @return HasMany<Prize, $this>
* @return HasMany<GiveawayPrize, $this>
*/
public function prizes(): HasMany
{
return $this->hasMany(Prize::class);
return $this->hasMany(GiveawayPrize::class);
}
}
@@ -21,7 +21,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use AllowDynamicProperties;
/**
* App\Models\ClaimedPrize.
* App\Models\GiveawayClaimedPrize.
*
* @property int $id
* @property int $user_id
@@ -32,7 +32,7 @@ use AllowDynamicProperties;
* @property \Illuminate\Support\Carbon|null $updated_at
*/
#[AllowDynamicProperties]
final class ClaimedPrize extends Model
final class GiveawayClaimedPrize extends Model
{
/**
* The attributes that aren't mass assignable.
@@ -52,12 +52,12 @@ final class ClaimedPrize extends Model
}
/**
* Get the event that owns this claimed prize.
* Get the giveaway that owns this claimed prize.
*
* @return BelongsTo<Event, $this>
* @return BelongsTo<Giveaway, $this>
*/
public function event(): BelongsTo
public function giveaway(): BelongsTo
{
return $this->belongsTo(Event::class);
return $this->belongsTo(Giveaway::class);
}
}
@@ -24,7 +24,7 @@ use AllowDynamicProperties;
* App\Models\Prize.
*
* @property int $id
* @property int $event_id
* @property int $giveaway_id
* @property string $type
* @property int $min
* @property int $max
@@ -33,7 +33,7 @@ use AllowDynamicProperties;
* @property \Illuminate\Support\Carbon|null $updated_at
*/
#[AllowDynamicProperties]
final class Prize extends Model
final class GiveawayPrize extends Model
{
/**
* The attributes that aren't mass assignable.
@@ -43,12 +43,12 @@ final class Prize extends Model
protected $guarded = [];
/**
* Get the event that owns the prize.
* Get the giveaway that owns the prize.
*
* @return BelongsTo<Event, $this>
* @return BelongsTo<Giveaway, $this>
*/
public function event(): BelongsTo
public function giveaway(): BelongsTo
{
return $this->belongsTo(Event::class);
return $this->belongsTo(Giveaway::class);
}
}
+2 -2
View File
@@ -983,11 +983,11 @@ final class User extends Authenticatable implements MustVerifyEmail
/**
* Get the prizes claimed by the user.
*
* @return HasMany<ClaimedPrize, $this>
* @return HasMany<GiveawayClaimedPrize, $this>
*/
public function claimedPrizes(): HasMany
{
return $this->hasMany(ClaimedPrize::class);
return $this->hasMany(GiveawayClaimedPrize::class);
}
/**
+2 -2
View File
@@ -6,7 +6,7 @@ namespace App\View\Composers;
use App\Enums\ModerationStatus;
use App\Models\Donation;
use App\Models\Event;
use App\Models\Giveaway;
use App\Models\Page;
use App\Models\Report;
use App\Models\Scopes\ApprovedScope;
@@ -45,7 +45,7 @@ class TopNavComposer
->where('user_read', '=', false),
)
->exists(),
'events' => Event::query()
'giveaways' => Giveaway::query()
->where('active', '=', true)
->withExists([
'claimedPrizes' => fn ($query) => $query
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Obi-wana
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::rename('events', 'giveaways');
Schema::rename('prizes', 'giveaway_prizes');
Schema::rename('claimed_prizes', 'giveaway_claimed_prizes');
Schema::table('giveaway_prizes', function (Blueprint $table): void {
$table->renameColumn('event_id', 'giveaway_id');
});
Schema::table('giveaway_claimed_prizes', function (Blueprint $table): void {
$table->renameColumn('event_id', 'giveaway_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::rename('giveaways', 'events');
Schema::rename('giveaway_prizes', 'prizes');
Schema::rename('giveaway_claimed_prizes', 'claimed_prizes');
Schema::table('giveaway_prizes', function (Blueprint $table): void {
$table->renameColumn('giveaway_id', 'event_id');
});
Schema::table('giveaway_claimed_prizes', function (Blueprint $table): void {
$table->renameColumn('giveaway_id', 'event_id');
});
}
};
+52 -51
View File
@@ -372,24 +372,6 @@ CREATE TABLE `chatrooms` (
UNIQUE KEY `chatrooms_name_unique` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `claimed_prizes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `claimed_prizes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`user_id` int unsigned NOT NULL,
`event_id` int unsigned NOT NULL,
`bon` bigint unsigned NOT NULL,
`fl_tokens` int unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `claimed_prizes_event_id_foreign` (`event_id`),
KEY `claimed_prizes_user_id_foreign` (`user_id`),
CONSTRAINT `claimed_prizes_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`),
CONSTRAINT `claimed_prizes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `comments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
@@ -505,22 +487,6 @@ CREATE TABLE `email_updates` (
CONSTRAINT `email_updates_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `events` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`icon` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`active` tinyint(1) NOT NULL,
`starts_at` date NOT NULL,
`ends_at` date NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `failed_jobs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
@@ -704,6 +670,57 @@ CREATE TABLE `git_updates` (
UNIQUE KEY `git_updates_hash_unique` (`hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `giveaway_claimed_prizes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `giveaway_claimed_prizes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`user_id` int unsigned NOT NULL,
`giveaway_id` int unsigned NOT NULL,
`bon` bigint unsigned NOT NULL,
`fl_tokens` int unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `claimed_prizes_event_id_foreign` (`giveaway_id`),
KEY `claimed_prizes_user_id_foreign` (`user_id`),
CONSTRAINT `claimed_prizes_event_id_foreign` FOREIGN KEY (`giveaway_id`) REFERENCES `giveaways` (`id`),
CONSTRAINT `claimed_prizes_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `giveaway_prizes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `giveaway_prizes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`giveaway_id` int unsigned NOT NULL,
`type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`min` int unsigned NOT NULL,
`max` int unsigned NOT NULL,
`weight` int unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `prizes_event_id_foreign` (`giveaway_id`),
CONSTRAINT `prizes_event_id_foreign` FOREIGN KEY (`giveaway_id`) REFERENCES `giveaways` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `giveaways`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `giveaways` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`icon` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`active` tinyint(1) NOT NULL,
`starts_at` date NOT NULL,
`ends_at` date NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `groups`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
@@ -1326,23 +1343,6 @@ CREATE TABLE `private_messages` (
CONSTRAINT `private_messages_sender_id_foreign` FOREIGN KEY (`sender_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `prizes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `prizes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`event_id` int unsigned NOT NULL,
`type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`min` int unsigned NOT NULL,
`max` int unsigned NOT NULL,
`weight` int unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `prizes_event_id_foreign` (`event_id`),
CONSTRAINT `prizes_event_id_foreign` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `regions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
@@ -3047,3 +3047,4 @@ INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (364,'2025_09_08_00
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (365,'2025_09_25_110038_alter_reports_create_assignee',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (366,'2025_11_08_094209_rename_warnings_torrent_to_torrent_id',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (367,'2025_11_18_080804_echoes_audibles_unique_keys',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (368,'2025_11_29_101934_update_events_rename_to_giveaways',1);
+2 -4
View File
@@ -14,17 +14,15 @@ declare(strict_types=1);
*/
return [
'add-event' => 'Add event',
'add-prize' => 'Add prize',
'edit-event' => 'Edit event',
'edit-prize' => 'Edit prize',
'ends-at' => 'Ends at',
'events' => 'Events',
'giveaway' => 'Giveaway',
'giveaways' => 'Giveaways',
'minimum' => 'Minimum',
'maximum' => 'Maximum',
'no-prizes' => 'No prizes.',
'prize' => 'Prize',
'prizes' => 'Prizes',
'starts-at' => 'Starts at',
'weight' => 'Weight',
];
@@ -162,10 +162,10 @@
<p class="form__group form__group--horizontal">
<a
class="form__button form__button--text"
href="{{ route('staff.events.index') }}"
href="{{ route('staff.giveaways.index') }}"
>
<i class="{{ config('other.font-awesome') }} fa-calendar-star"></i>
{{ __('event.events') }}
{{ __('event.giveaways') }}
</a>
</p>
<p class="form__group form__group--horizontal">
@@ -7,8 +7,8 @@
</a>
</li>
<li class="breadcrumbV2">
<a href="{{ route('staff.events.index') }}" class="breadcrumb__link">
{{ __('event.events') }}
<a href="{{ route('staff.giveaways.index') }}" class="breadcrumb__link">
{{ __('event.giveaways') }}
</a>
</li>
<li class="breadcrumb--active">
@@ -16,12 +16,12 @@
</li>
@endsection
@section('page', 'page__staff-event--create')
@section('page', 'page__staff-giveaway--create')
@section('main')
<section class="panelV2">
<h2 class="panel__heading">{{ __('event.add-event') }}</h2>
<form class="dialog__form" method="POST" action="{{ route('staff.events.store') }}">
<h2 class="panel__heading">{{ __('common.add') }} {{ __('event.giveaway') }}</h2>
<form class="dialog__form" method="POST" action="{{ route('staff.giveaways.store') }}">
@csrf
<p class="form__group">
<input
@@ -64,13 +64,13 @@
<p class="form__group">
<input id="starts_at" class="form__text" name="starts_at" type="date" />
<label class="form__label form__label--floating" for="starts_at">
{{ __('event.starts-at') }}
{{ __('common.starts-at') }}
</label>
</p>
<p class="form__group">
<input id="ends_at" class="form__text" name="ends_at" type="date" />
<label class="form__label form__label--floating" for="ends_at">
{{ __('event.ends-at') }}
{{ __('common.ends-at') }}
</label>
</p>
</div>
@@ -7,27 +7,27 @@
</a>
</li>
<li class="breadcrumbV2">
<a href="{{ route('staff.events.index') }}" class="breadcrumb__link">
{{ __('event.events') }}
<a href="{{ route('staff.giveaways.index') }}" class="breadcrumb__link">
{{ __('event.giveaways') }}
</a>
</li>
<li class="breadcrumbV2">
{{ $event->name }}
{{ $giveaway->name }}
</li>
<li class="breadcrumb--active">
{{ __('common.edit') }}
</li>
@endsection
@section('page', 'page__staff-event--edit')
@section('page', 'page__staff-giveaway--edit')
@section('main')
<section class="panelV2">
<h2 class="panel__heading">{{ __('event.edit-event') }}</h2>
<h2 class="panel__heading">{{ __('common.edit') }} {{ __('event.giveaway') }}</h2>
<form
class="dialog__form"
method="POST"
action="{{ route('staff.events.update', ['event' => $event]) }}"
action="{{ route('staff.giveaways.update', ['giveaway' => $giveaway]) }}"
>
@csrf
@method('PATCH')
@@ -39,7 +39,7 @@
autocomplete="off"
name="name"
required
value="{{ $event->name }}"
value="{{ $giveaway->name }}"
/>
<label class="form__label form__label--floating" for="name">
{{ __('common.name') }}
@@ -47,7 +47,7 @@
</p>
<p class="form__group">
<textarea id="description" class="form__textarea" name="description" required>
{{ $event->description }}</textarea
{{ $giveaway->description }}</textarea
>
<label class="form__label form__label--floating" for="description">
{{ __('common.description') }}
@@ -61,7 +61,7 @@
autocomplete="off"
name="icon"
required
value="{{ $event->icon }}"
value="{{ $giveaway->icon }}"
/>
<label class="form__label form__label--floating" for="icon">
{{ __('common.icon') }}
@@ -74,11 +74,11 @@
class="form__text"
name="starts_at"
type="date"
value="{{ $event->starts_at->format('Y-m-d') }}"
value="{{ $giveaway->starts_at->format('Y-m-d') }}"
required
/>
<label class="form__label form__label--floating" for="starts_at">
{{ __('event.starts-at') }}
{{ __('common.starts-at') }}
</label>
</p>
<p class="form__group">
@@ -87,11 +87,11 @@
class="form__text"
name="ends_at"
type="date"
value="{{ $event->ends_at->format('Y-m-d') }}"
value="{{ $giveaway->ends_at->format('Y-m-d') }}"
required
/>
<label class="form__label form__label--floating" for="ends_at">
{{ __('event.ends-at') }}
{{ __('common.ends-at') }}
</label>
</p>
</div>
@@ -103,7 +103,7 @@
id="active"
name="active"
value="1"
@checked($event->active)
@checked($giveaway->active)
/>
<label class="form__label" for="active">{{ __('common.active') }}?</label>
</p>
@@ -134,11 +134,11 @@
<form
class="dialog__form"
method="POST"
action="{{ route('staff.events.prizes.store', ['event' => $event]) }}"
action="{{ route('staff.giveaways.prizes.store', ['giveaway' => $giveaway]) }}"
x-bind="dialogForm"
>
@csrf
<input type="hidden" name="event_id" value="{{ $event->id }}" />
<input type="hidden" name="giveaway_id" value="{{ $giveaway->id }}" />
<p class="form__group">
<select name="type" id="type" class="form__select" required>
<option hidden disabled selected value=""></option>
@@ -221,7 +221,7 @@
<th>{{ __('common.actions') }}</th>
</thead>
<tbody>
@forelse ($event->prizes as $prize)
@forelse ($giveaway->prizes as $prize)
<tr>
<td>
@switch($prize->type)
@@ -254,15 +254,15 @@
<form
class="dialog__form"
method="POST"
action="{{ route('staff.events.prizes.update', ['event' => $event, 'prize' => $prize]) }}"
action="{{ route('staff.giveaways.prizes.update', ['giveaway' => $giveaway, 'prize' => $prize]) }}"
x-bind="dialogForm"
>
@csrf
@method('PATCH')
<input
type="hidden"
name="event_id"
value="{{ $event->id }}"
name="giveaway_id"
value="{{ $giveaway->id }}"
/>
<p class="form__group">
<select
@@ -273,13 +273,13 @@
>
<option
value="bon"
@selected($event->type === 'bon')
@selected($giveaway->type === 'bon')
>
{{ __('bon.bon') }}
</option>
<option
value="fl_tokens"
@selected($event->type === 'fl_tokens')
@selected($giveaway->type === 'fl_tokens')
>
{{ __('common.fl_tokens') }}
</option>
@@ -367,7 +367,7 @@
</li>
<li class="data-table__action">
<form
action="{{ route('staff.events.prizes.destroy', ['event' => $event, 'prize' => $prize]) }}"
action="{{ route('staff.giveaways.prizes.destroy', ['giveaway' => $giveaway, 'prize' => $prize]) }}"
method="POST"
x-data="confirmation"
>
@@ -376,7 +376,7 @@
<button
x-on:click.prevent="confirmAction"
class="form__button form__button--text"
data-b64-deletion-message="{{ base64_encode('Are you sure you want to remove this prize (Type: ' . $prize->type . ', Min: ' . $prize->min . ', Max: ' . $prize->max . ', Weight: ' . $prize->weight . ') from this event (.' . $event->name . ')?') }}"
data-b64-deletion-message="{{ base64_encode('Are you sure you want to remove this prize (Type: ' . $prize->type . ', Min: ' . $prize->min . ', Max: ' . $prize->max . ', Weight: ' . $prize->weight . ') from this giveaways (.' . $giveaway->name . ')?') }}"
>
{{ __('common.delete') }}
</button>
@@ -7,21 +7,21 @@
</a>
</li>
<li class="breadcrumb--active">
{{ __('event.events') }}
{{ __('event.giveaways') }}
</li>
@endsection
@section('page', 'page__staff-event--index')
@section('page', 'page__staff-giveaways--index')
@section('main')
<section class="panelV2">
<header class="panel__header">
<h2 class="panel__heading">{{ __('event.events') }}</h2>
<h2 class="panel__heading">{{ __('event.giveaways') }}</h2>
<div class="panel__actions">
<div class="panel__action">
<a
class="form__button form__button--text"
href="{{ route('staff.events.create') }}"
href="{{ route('staff.giveaways.create') }}"
>
{{ __('common.add') }}
</a>
@@ -40,31 +40,33 @@
</tr>
</thead>
<tbody>
@foreach ($events as $event)
@foreach ($giveaways as $giveaway)
<tr>
<td>
<a href="{{ route('staff.events.edit', ['event' => $event]) }}">
{{ $event->name }}
<a
href="{{ route('staff.giveaways.edit', ['giveaway' => $giveaway]) }}"
>
{{ $giveaway->name }}
</a>
</td>
<td>
<time
datetime="{{ $event->starts_at }}"
title="{{ $event->starts_at }}"
datetime="{{ $giveaway->starts_at }}"
title="{{ $giveaway->starts_at }}"
>
{{ $event->starts_at->format('Y-m-d') }}
{{ $giveaway->starts_at->format('Y-m-d') }}
</time>
</td>
<td>
<time
datetime="{{ $event->ends_at }}"
title="{{ $event->ends_at }}"
datetime="{{ $giveaway->ends_at }}"
title="{{ $giveaway->ends_at }}"
>
{{ $event->ends_at->format('Y-m-d') }}
{{ $giveaway->ends_at->format('Y-m-d') }}
</time>
</td>
<td>
@if ($event->active)
@if ($giveaway->active)
<i
class="{{ config('other.font-awesome') }} fa-check text-green"
></i>
@@ -78,7 +80,7 @@
<menu class="data-table__actions">
<li class="data-table__action">
<a
href="{{ route('staff.events.edit', ['event' => $event]) }}"
href="{{ route('staff.giveaways.edit', ['giveaway' => $giveaway]) }}"
class="form__button form__button--text"
>
{{ __('common.edit') }}
@@ -86,7 +88,7 @@
</li>
<li class="data-table__action">
<form
action="{{ route('staff.events.destroy', ['event' => $event]) }}"
action="{{ route('staff.giveaways.destroy', ['giveaway' => $giveaway]) }}"
method="POST"
x-data="confirmation"
>
@@ -94,7 +96,7 @@
@method('DELETE')
<button
x-on:click.prevent="confirmAction"
data-b64-deletion-message="{{ base64_encode('Are you sure you want to delete this event: ' . $event->name . '?') }}"
data-b64-deletion-message="{{ base64_encode('Are you sure you want to delete this giveaway: ' . $giveaway->name . '?') }}"
class="form__button form__button--text"
>
{{ __('common.delete') }}
@@ -2,51 +2,51 @@
@section('breadcrumbs')
<li class="breadcrumb--active">
{{ __('event.events') }}
{{ __('event.giveaways') }}
</li>
@endsection
@section('page', 'page__event--index')
@section('page', 'page__giveaway--index')
@section('main')
<section class="panelV2">
<h2 class="panel__heading">{{ __('event.events') }}</h2>
<h2 class="panel__heading">{{ __('event.giveaways') }}</h2>
<div class="data-table-wrapper">
<table class="data-table">
<thead>
<tr>
<th>{{ __('common.name') }}</th>
<th>{{ __('event.starts-at') }}</th>
<th>{{ __('event.ends-at') }}</th>
<th>{{ __('common.starts-at') }}</th>
<th>{{ __('common.ends-at') }}</th>
<th>{{ __('common.active') }}</th>
</tr>
</thead>
<tbody>
@foreach ($events as $event)
@foreach ($giveaways as $giveaway)
<tr>
<td>
<a href="{{ route('events.show', ['event' => $event]) }}">
{{ $event->name }}
<a href="{{ route('giveaways.show', ['giveaway' => $giveaway]) }}">
{{ $giveaway->name }}
</a>
</td>
<td>
<time
datetime="{{ $event->starts_at }}"
title="{{ $event->starts_at }}"
datetime="{{ $giveaway->starts_at }}"
title="{{ $giveaway->starts_at }}"
>
{{ $event->starts_at->format('Y-m-d') }}
{{ $giveaway->starts_at->format('Y-m-d') }}
</time>
</td>
<td>
<time
datetime="{{ $event->ends_at }}"
title="{{ $event->ends_at }}"
datetime="{{ $giveaway->ends_at }}"
title="{{ $giveaway->ends_at }}"
>
{{ $event->ends_at->format('Y-m-d') }}
{{ $giveaway->ends_at->format('Y-m-d') }}
</time>
</td>
<td>
@if ($event->active)
@if ($giveaway->active)
<i
class="{{ config('other.font-awesome') }} fa-check text-green"
></i>
@@ -2,23 +2,23 @@
@section('breadcrumbs')
<li class="breadcrumbV2">
<a href="{{ route('events.index') }}" class="breadcrumb__link">
{{ __('event.events') }}
<a href="{{ route('giveaways.index') }}" class="breadcrumb__link">
{{ __('event.giveaways') }}
</a>
</li>
<li class="breadcrumb--active">
{{ $event->name }}
{{ $giveaway->name }}
</li>
@endsection
@section('page', 'page__event--show')
@section('page', 'page__giveaway--show')
@section('main')
<section class="panelV2">
<h2 class="panel__heading">{{ $event->name }}</h2>
<h2 class="panel__heading">{{ $giveaway->name }}</h2>
<div class="panel__body">
<ol class="events__list">
@foreach (\Carbon\CarbonPeriod::create($event->starts_at, $event->ends_at) as $i => $date)
@foreach (\Carbon\CarbonPeriod::create($giveaway->starts_at, $giveaway->ends_at) as $i => $date)
<li class="events__list-item">
<article class="events__prize">
<h3 class="events__prize-heading">
@@ -27,7 +27,7 @@
@if ($prize = $userPrizes->get($i)?->first())
<i
class="events__prize-icon events__prize-icon--today-claimed fad {{ $event->icon }}"
class="events__prize-icon events__prize-icon--today-claimed fad {{ $giveaway->icon }}"
></i>
@if ($prize->bon > 0 || $prize->fl_tokens > 0)
<ul class="events__prize-winnings-list">
@@ -59,21 +59,21 @@
@else
@if (now()->isBefore($date))
<i
class="events__prize-icon events__prize-icon--future fad {{ $event->icon }}"
class="events__prize-icon events__prize-icon--future fad {{ $giveaway->icon }}"
></i>
<i class="events__prize-message">Check back later!</i>
@elseif (now()->isAfter($date->addDay(1)))
<i
class="events__prize-icon events__prize-icon--past fad {{ $event->icon }}"
class="events__prize-icon events__prize-icon--past fad {{ $giveaway->icon }}"
></i>
<i class="events__prize-message">{{ __('common.expired') }}</i>
@else
<i
class="events__prize-icon events__prize-icon--today-unclaimed fad {{ $event->icon }} fa-beat-fade"
class="events__prize-icon events__prize-icon--today-unclaimed fad {{ $giveaway->icon }} fa-beat-fade"
></i>
<form
class="form"
action="{{ route('events.claims.store', ['event' => $event]) }}"
action="{{ route('giveaways.claims.store', ['giveaway' => $giveaway]) }}"
method="POST"
style="display: contents"
>
@@ -100,7 +100,7 @@
<section class="panelV2">
<h2 class="panel__heading">{{ __('common.info') }}</h2>
<div class="panel__body">
{{ $event->description }}
{{ $giveaway->description }}
</div>
</section>
@endsection
+5 -5
View File
@@ -165,18 +165,18 @@
<a tabindex="0">
<div class="top-nav--left__container">
{{ __('common.other') }}
@if ($events->contains(fn ($event) => ! $event->claimed_prizes_exists && $event->ends_at->endOfDay()->isFuture()))
@if ($giveaways->contains(fn ($giveaway) => ! $giveaway->claimed_prizes_exists && $giveaway->ends_at->endOfDay()->isFuture()))
<x-animation.notification />
@endif
</div>
</a>
<ul>
@foreach ($events as $event)
@foreach ($giveaways as $giveaway)
<li>
<a href="{{ route('events.show', ['event' => $event]) }}">
<a href="{{ route('giveaways.show', ['giveaway' => $giveaway]) }}">
<i class="{{ config('other.font-awesome') }} fa-calendar-star"></i>
{{ $event->name }}
@if (! $event->claimed_prizes_exists && $event->ends_at->endOfDay()->isFuture())
{{ $giveaway->name }}
@if (! $giveaway->claimed_prizes_exists && $giveaway->ends_at->endOfDay()->isFuture())
<x-animation.notification />
@endif
</a>
+18 -18
View File
@@ -124,15 +124,15 @@ Route::middleware('language')->group(function (): void {
Route::post('/store', [App\Http\Controllers\DonationController::class, 'store'])->name('store');
});
// Events
Route::prefix('events')->name('events.')->group(function (): void {
Route::get('/', [App\Http\Controllers\EventController::class, 'index'])->name('index');
Route::prefix('{event}')->group(function (): void {
Route::get('/', [App\Http\Controllers\EventController::class, 'show'])->name('show');
// Giveaways
Route::prefix('giveaways')->name('giveaways.')->group(function (): void {
Route::get('/', [App\Http\Controllers\GiveawayController::class, 'index'])->name('index');
Route::prefix('{giveaway}')->group(function (): void {
Route::get('/', [App\Http\Controllers\GiveawayController::class, 'show'])->name('show');
//Claims
Route::prefix('claims')->name('claims.')->group(function (): void {
Route::post('/', [App\Http\Controllers\ClaimedPrizeController::class, 'store'])->name('store');
Route::post('/', [App\Http\Controllers\GiveawayClaimedPrizeController::class, 'store'])->name('store');
});
});
});
@@ -841,21 +841,21 @@ Route::middleware('language')->group(function (): void {
Route::get('/', [App\Http\Controllers\Staff\EmailUpdateController::class, 'index'])->name('index');
});
// Events
Route::prefix('events')->name('events.')->group(function (): void {
Route::get('/', [App\Http\Controllers\Staff\EventController::class, 'index'])->name('index');
Route::get('/create', [App\Http\Controllers\Staff\EventController::class, 'create'])->name('create');
Route::post('/', [App\Http\Controllers\Staff\EventController::class, 'store'])->name('store');
Route::prefix('{event}')->group(function (): void {
Route::get('/edit', [App\Http\Controllers\Staff\EventController::class, 'edit'])->name('edit');
Route::patch('/', [App\Http\Controllers\Staff\EventController::class, 'update'])->name('update');
Route::delete('/', [App\Http\Controllers\Staff\EventController::class, 'destroy'])->name('destroy');
// Giveaways
Route::prefix('giveaways')->name('giveaways.')->group(function (): void {
Route::get('/', [App\Http\Controllers\Staff\GiveawayController::class, 'index'])->name('index');
Route::get('/create', [App\Http\Controllers\Staff\GiveawayController::class, 'create'])->name('create');
Route::post('/', [App\Http\Controllers\Staff\GiveawayController::class, 'store'])->name('store');
Route::prefix('{giveaway}')->group(function (): void {
Route::get('/edit', [App\Http\Controllers\Staff\GiveawayController::class, 'edit'])->name('edit');
Route::patch('/', [App\Http\Controllers\Staff\GiveawayController::class, 'update'])->name('update');
Route::delete('/', [App\Http\Controllers\Staff\GiveawayController::class, 'destroy'])->name('destroy');
// Prizes
Route::prefix('prizes')->name('prizes.')->group(function (): void {
Route::post('/', [App\Http\Controllers\Staff\PrizeController::class, 'store'])->name('store');
Route::patch('/{prize}', [App\Http\Controllers\Staff\PrizeController::class, 'update'])->name('update');
Route::delete('/{prize}', [App\Http\Controllers\Staff\PrizeController::class, 'destroy'])->name('destroy');
Route::post('/', [App\Http\Controllers\Staff\GiveawayPrizeController::class, 'store'])->name('store');
Route::patch('/{prize}', [App\Http\Controllers\Staff\GiveawayPrizeController::class, 'update'])->name('update');
Route::delete('/{prize}', [App\Http\Controllers\Staff\GiveawayPrizeController::class, 'destroy'])->name('destroy');
});
});
});