Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .cspell/laravel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dontflash
dontrelease
dontreport
ehlo
encryptable
encrypter
mimetypes
mysql
Expand Down
27 changes: 13 additions & 14 deletions app/Models/Donation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace App\Models;

use App\Enums\ModerationStatus;
use App\Traits\Encryptable;
use Illuminate\Database\Eloquent\Model;

/**
Expand All @@ -37,16 +36,25 @@
*/
class Donation extends Model
{
use Encryptable;

final public const int PENDING = 0;
final public const int APPROVED = 1;
final public const int REJECTED = 2;

/**
* Get the attributes that should be cast.
*
* @return array{user_id: 'int', gifted_user_id: 'int', status: class-string<ModerationStatus>, package_id: 'int', transaction: 'string', is_gifted: 'bool', starts_at: 'datetime', ends_at: 'datetime', created_at: 'datetime', updated_at: 'datetime'}
* @return array{
* user_id: 'int',
* gifted_user_id: 'int',
* status: class-string<ModerationStatus>,
* package_id: 'int',
* transaction: 'encrypted',
* is_gifted: 'bool',
* starts_at: 'datetime',
* ends_at: 'datetime',
* created_at: 'datetime',
* updated_at: 'datetime'
* }
*/
protected function casts(): array
{
Expand All @@ -55,7 +63,7 @@ protected function casts(): array
'gifted_user_id' => 'int',
'status' => ModerationStatus::class,
'package_id' => 'int',
'transaction' => 'string',
'transaction' => 'encrypted',
'is_gifted' => 'bool',
'starts_at' => 'datetime',
'ends_at' => 'datetime',
Expand All @@ -71,15 +79,6 @@ protected function casts(): array
*/
protected $guarded = ['id'];

/**
* The Attributes That Are Encrypted.
*
* @var string[]
*/
protected array $encryptable = [
'transaction',
];

/**
* Belongs To A User.
*
Expand Down
21 changes: 12 additions & 9 deletions app/Models/Seedbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace App\Models;

use App\Traits\Auditable;
use App\Traits\Encryptable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

Expand All @@ -34,21 +33,25 @@
class Seedbox extends Model
{
use Auditable;
use Encryptable;

/** @use HasFactory<\Database\Factories\SeedboxFactory> */
use HasFactory;

protected $guarded = [];

/**
* The Attributes That Are Encrypted.
* Get the attributes that should be cast.
*
* @var string[]
* @return array{
* ip: 'encrypted',
* }
*/
protected array $encryptable = [
'ip',
];

protected $guarded = [];
protected function casts(): array
{
return [
'ip' => 'encrypted',
];
}

/**
* Belongs To A User.
Expand Down
48 changes: 0 additions & 48 deletions app/Traits/Encryptable.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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 <[email protected]>
* @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\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('seedboxes')
->lazyById()
->each(function (object $seedbox): void {
/** @var object{id: int, ip: string} $seedbox */
DB::table('seedboxes')
->where('id', '=', $seedbox->id)
->update([
'ip' => Crypt::encryptString(Crypt::decrypt($seedbox->ip))
]);
});

DB::table('donations')
->lazyById()
->each(function (object $donation): void {
/** @var object{id: int, transaction: string} $donation */
DB::table('donations')
->where('id', '=', $donation->id)
->update([
'transaction' => Crypt::encryptString(Crypt::decrypt($donation->transaction)),
]);
});
}
};
1 change: 1 addition & 0 deletions database/schema/mysql-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3005,3 +3005,4 @@ INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (354,'2025_06_18_00
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (355,'2025_06_18_040627_alter_requests_drop_claimed',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (356,'2025_06_21_234021_alter_requests_drop_votes',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (357,'2025_07_15_061844_add_block_order_to_user_settings',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (358,'2025_07_17_061745_reencrypt_encrypted_columns',1);