set broadcasting in admin and setup wizard

This commit is contained in:
Čarodej
2022-03-16 09:37:17 +01:00
parent 4bab179e17
commit 9d955799d3
16 changed files with 666 additions and 161 deletions
@@ -0,0 +1,58 @@
<?php
namespace Domain\Settings\Controllers;
use Artisan;
use Domain\Settings\Requests\StoreBroadcastServiceCredentialsRequest;
use Illuminate\Http\Response;
class StoreBroadcastServiceCredentialsController
{
/**
* Configure stripe additionally
*/
public function __invoke(StoreBroadcastServiceCredentialsRequest $request): Response
{
// Abort in demo mode
abort_if(is_demo(), 204, 'Done.');
// Get and store credentials
if (!app()->runningUnitTests()) {
$credentials = [
'pusher' => [
'BROADCAST_DRIVER' => 'pusher',
'PUSHER_APP_ID' => $request->input('id'),
'PUSHER_APP_KEY' => $request->input('key'),
'PUSHER_APP_SECRET' => $request->input('secret'),
'PUSHER_APP_CLUSTER' => $request->input('cluster'),
'PUSHER_APP_HOST' => '',
'PUSHER_APP_PORT' => '',
],
'native' => [
'BROADCAST_DRIVER' => 'pusher',
'PUSHER_APP_ID' => 'local',
'PUSHER_APP_KEY' => 'local',
'PUSHER_APP_SECRET' => 'local',
'PUSHER_APP_CLUSTER' => 'local',
'PUSHER_APP_HOST' => $request->input('host'),
'PUSHER_APP_PORT' => $request->input('port'),
],
'none' => [
'BROADCAST_DRIVER' => 'null',
],
];
// Store credentials into the .env file
setEnvironmentValue($credentials[$request->input('driver')]);
// Clear cache
if (!is_dev()) {
Artisan::call('cache:clear');
Artisan::call('config:clear');
Artisan::call('config:cache');
}
}
return response('Done', 204);
}
}
@@ -0,0 +1,36 @@
<?php
namespace Domain\Settings\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreBroadcastServiceCredentialsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'driver' => 'required|string',
'id' => 'sometimes|nullable|string',
'key' => 'sometimes|nullable|string',
'secret' => 'sometimes|nullable|string',
'cluster' => 'sometimes|nullable|string',
'port' => 'sometimes|nullable|string',
'host' => 'sometimes|nullable|string',
];
}
}