Update domain block commands

This commit is contained in:
Daniel Supernault 2023-12-21 03:48:08 -07:00
parent f3f0175c84
commit 519c7a3735
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
2 changed files with 8 additions and 0 deletions

View file

@ -4,6 +4,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\User;
use App\Models\DefaultDomainBlock;
use App\Models\UserDomainBlock;
use function Laravel\Prompts\text;
use function Laravel\Prompts\confirm;
@ -31,6 +32,7 @@ class AddUserDomainBlock extends Command
public function handle()
{
$domain = text('Enter domain you want to block');
$domain = strtolower($domain);
$domain = $this->validateDomain($domain);
$this->processBlocks($domain);
return;
@ -74,6 +76,9 @@ class AddUserDomainBlock extends Command
protected function processBlocks($domain)
{
DefaultDomainBlock::updateOrCreate([
'domain' => $domain
]);
progress(
label: 'Updating user domain blocks...',
steps: User::lazyById(500),

View file

@ -4,6 +4,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\User;
use App\Models\DefaultDomainBlock;
use App\Models\UserDomainBlock;
use function Laravel\Prompts\text;
use function Laravel\Prompts\confirm;
@ -31,6 +32,7 @@ class DeleteUserDomainBlock extends Command
public function handle()
{
$domain = text('Enter domain you want to unblock');
$domain = strtolower($domain);
$domain = $this->validateDomain($domain);
$this->processUnblocks($domain);
return;
@ -74,6 +76,7 @@ class DeleteUserDomainBlock extends Command
protected function processUnblocks($domain)
{
DefaultDomainBlock::whereDomain($domain)->delete();
progress(
label: 'Updating user domain blocks...',
steps: UserDomainBlock::whereDomain($domain)->lazyById(500),