Files
wticreatorstudio/Modules/StudioPlus/Console/StudioPlusChannelCreate.php
T
2024-02-12 22:54:20 -05:00

58 lines
1.3 KiB
PHP

<?php
namespace Modules\StudioPlus\Console;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
use Modules\StudioPlus\Entities\StudioPlusUser;
use Symfony\Component\Console\Input\InputOption;
use Modules\StudioPlus\Entities\StudioPlusChannel;
use Symfony\Component\Console\Input\InputArgument;
class StudioPlusChannelCreate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'studioplus:channel';
/**
* The console command description.
*
* @var string
*/
protected $description = "Create channel for users";
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
StudioPlusUser::query()
->whereDoesntHave('channel')
->each(function ($user) {
StudioPlusChannel::query()
->create(
[
'user_id' => $user->id,
'name' => Str::random(30)
]
);
});
}
}