Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Meet/RoomCreate.php
- This file was moved from src/app/Console/Commands/OpenVidu/RoomCreate.php.
<?php | <?php | ||||
namespace App\Console\Commands\OpenVidu; | namespace App\Console\Commands\Meet; | ||||
use App\Console\Command; | use App\Console\Command; | ||||
class RoomCreate extends Command | class RoomCreate extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'openvidu:room-create {user} {room}'; | protected $signature = 'meet:room-create {user} {room}'; | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Create a room for a user'; | protected $description = 'Create a room for a user'; | ||||
Show All 12 Lines | public function handle() | ||||
$roomName = $this->argument('room'); | $roomName = $this->argument('room'); | ||||
if (!preg_match('/^[a-zA-Z0-9_-]{1,16}$/', $roomName)) { | if (!preg_match('/^[a-zA-Z0-9_-]{1,16}$/', $roomName)) { | ||||
$this->error("Invalid room name. Should be up to 16 characters ([a-zA-Z0-9_-])."); | $this->error("Invalid room name. Should be up to 16 characters ([a-zA-Z0-9_-])."); | ||||
return 1; | return 1; | ||||
} | } | ||||
$room = \App\OpenVidu\Room::where('name', $roomName)->first(); | $room = \App\Meet\Room::where('name', $roomName)->first(); | ||||
if ($room) { | if ($room) { | ||||
$this->error("Room already exists."); | $this->error("Room already exists."); | ||||
return 1; | return 1; | ||||
} | } | ||||
\App\OpenVidu\Room::create( | \App\Meet\Room::create([ | ||||
[ | |||||
'name' => $roomName, | 'name' => $roomName, | ||||
'user_id' => $user->id | 'user_id' => $user->id | ||||
] | ]); | ||||
); | |||||
} | } | ||||
} | } |