mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-18 18:59:34 -06:00
68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* 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 HDVinnie <hdinnovations@protonmail.com>
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
|
*/
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\PersonalFreeleech;
|
|
use App\Models\PrivateMessage;
|
|
use App\Services\Unit3dAnnounce;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
/**
|
|
* @see \Tests\Unit\Console\Commands\AutoRemovePersonalFreeleechTest
|
|
*/
|
|
class AutoRemovePersonalFreeleech extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'auto:remove_personal_freeleech';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Automatically Removes A Users Personal Freeleech If It Has Expired';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$current = Carbon::now();
|
|
$personalFreeleech = PersonalFreeleech::where('created_at', '<', $current->copy()->subDays(1)->toDateTimeString())->get();
|
|
|
|
foreach ($personalFreeleech as $pfl) {
|
|
// Send Private Message
|
|
$pm = new PrivateMessage();
|
|
$pm->sender_id = 1;
|
|
$pm->receiver_id = $pfl->user_id;
|
|
$pm->subject = 'Personal 24 Hour Freeleech Expired';
|
|
$pm->message = 'Your [b]Personal 24 Hour Freeleech[/b] has expired! Feel free to reenable it in the BON Store! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]';
|
|
$pm->save();
|
|
|
|
// Delete The Record From DB
|
|
$pfl->delete();
|
|
|
|
cache()->forget('personal_freeleech:'.$pfl->user_id);
|
|
Unit3dAnnounce::removePersonalFreeleech($pfl->user_id);
|
|
}
|
|
|
|
$this->comment('Automated Removal User Personal Freeleech Command Complete');
|
|
}
|
|
}
|