laravel-websockets/src/LaravelEcho/Http/Controllers/FetchChannel.php

20 lines
527 B
PHP
Raw Normal View History

2018-11-21 11:13:40 +00:00
<?php
namespace BeyondCode\LaravelWebSockets\LaravelEcho\Http\Controllers;
use Illuminate\Http\Request;
2018-11-22 20:36:25 +00:00
use Symfony\Component\HttpKernel\Exception\HttpException;
2018-11-21 11:13:40 +00:00
2018-11-22 20:36:25 +00:00
class FetchChannel extends EchoController
2018-11-21 11:13:40 +00:00
{
public function __invoke(Request $request)
{
2018-11-22 21:02:36 +00:00
$channel = $this->channelManager->find($request->appId, $request->channelName);
2018-11-22 17:13:43 +00:00
2018-11-22 21:02:36 +00:00
if (is_null($channel)) {
throw new HttpException(404, 'Unknown channel "'.$request->channelName.'"');
2018-11-21 14:42:04 +00:00
}
2018-11-21 23:12:23 +00:00
2018-11-22 21:02:36 +00:00
return $channel->toArray();
2018-11-21 11:13:40 +00:00
}
}