tenantId = null; $this->addTenantId(); if (!$this->tenantId) { throw new RuntimeException('\'tenantId\' must be a valid string.'); } \dispatch_sync(new ShowroomExport($this->tenantId)); } /** * Add a role to the user. * * @return void */ private function addTenantId(): void { while (is_null($this->tenantId)) { try { $tmp = $this->choice( 'Select a tenant', Tenant::all()->pluck('id')->toArray(), Tenant::query()->first()->id, ); $validator = Validator::make(['tenant_id' => $tmp], [ 'tenant_id' => 'required' ]); $validator->validate(); $this->tenantId = $tmp; } catch (ValidationException $e) { $this->error(sprintf( 'Please choose from the selection %s', \implode(',', collect($e->errors())->flatten()->all()) )); continue; } //end try }; //end while } }