wip
This commit is contained in:
parent
f617240543
commit
62d9dff008
|
|
@ -16,6 +16,7 @@ return [
|
||||||
'key' => env('PUSHER_APP_KEY'),
|
'key' => env('PUSHER_APP_KEY'),
|
||||||
'secret' => env('PUSHER_APP_SECRET'),
|
'secret' => env('PUSHER_APP_SECRET'),
|
||||||
'enable_client_messages' => false,
|
'enable_client_messages' => false,
|
||||||
|
'enable_statistics' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateWebSocketsStatisticsEntriesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('websockets_statistics_entries', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->nullableTimestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('websockets_statistics_entries');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,9 @@ class App
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
public $clientMessagesEnabled = false;
|
public $clientMessagesEnabled = false;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
public $statisticsEnabled = true;
|
||||||
|
|
||||||
public static function findById($appId)
|
public static function findById($appId)
|
||||||
{
|
{
|
||||||
return app(AppProvider::class)->findById($appId);
|
return app(AppProvider::class)->findById($appId);
|
||||||
|
|
@ -61,4 +64,11 @@ class App
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function enableStatistics(bool $enabled = true)
|
||||||
|
{
|
||||||
|
$this->statisticsEnabled = $enabled;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class ConfigAppProvider implements AppProvider
|
||||||
|
|
||||||
protected function instanciate(?array $appAttributes): ?App
|
protected function instanciate(?array $appAttributes): ?App
|
||||||
{
|
{
|
||||||
if (! $appAttributes) {
|
if (!$appAttributes) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,9 +58,10 @@ class ConfigAppProvider implements AppProvider
|
||||||
$app->setName($appAttributes['name']);
|
$app->setName($appAttributes['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($appAttributes['enable_client_messages'] ?? false) {
|
$app
|
||||||
$app->enableClientMessages();
|
->enableClientMessages($appAttributes['enable_client_messages'])
|
||||||
}
|
->enableStatistics($appAttributes['enable_statistics']);
|
||||||
|
|
||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BeyondCode\LaravelWebSockets\Statistics;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class WebSocketsStatisticsEntry extends Model
|
||||||
|
{
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
protected $table = 'websockets_statistics_entries';
|
||||||
|
}
|
||||||
|
|
@ -21,6 +21,12 @@ class WebSocketsServiceProvider extends ServiceProvider
|
||||||
__DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
|
__DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
|
||||||
], 'config');
|
], 'config');
|
||||||
|
|
||||||
|
if (! class_exists('CreateWebSocketsStatisticsEntries')) {
|
||||||
|
$this->publishes([
|
||||||
|
__DIR__.'/../database/migrations/cretae_websockets_statistics_entries_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_cretae_websockets_statistics_entries_table.php'),
|
||||||
|
], 'migrations');
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerRouteMacro();
|
$this->registerRouteMacro();
|
||||||
|
|
||||||
$this->registerDashboardGate();
|
$this->registerDashboardGate();
|
||||||
|
|
|
||||||
|
|
@ -32,5 +32,6 @@ class ConfigAppProviderTest extends TestCase
|
||||||
$this->assertEquals('TestKey', $app->key);
|
$this->assertEquals('TestKey', $app->key);
|
||||||
$this->assertEquals('TestSecret', $app->secret);
|
$this->assertEquals('TestSecret', $app->secret);
|
||||||
$this->assertFalse($app->clientMessagesEnabled);
|
$this->assertFalse($app->clientMessagesEnabled);
|
||||||
|
$this->assertTrue($app->statisticsEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,6 +35,7 @@ class PusherClientMessageTest extends TestCase
|
||||||
'key' => 'TestKey',
|
'key' => 'TestKey',
|
||||||
'secret' => 'TestSecret',
|
'secret' => 'TestSecret',
|
||||||
'enable_client_messages' => true,
|
'enable_client_messages' => true,
|
||||||
|
'enable_statistics' => true,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
'key' => 'TestKey',
|
'key' => 'TestKey',
|
||||||
'secret' => 'TestSecret',
|
'secret' => 'TestSecret',
|
||||||
'enable_client_messages' => false,
|
'enable_client_messages' => false,
|
||||||
|
'enable_statistics' => true,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue