2017-09-03 02:35:33 +00:00
|
|
|
<?php
|
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
namespace Pterodactyl\Http\ViewComposers\Server;
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
use Illuminate\View\View;
|
2017-10-19 03:32:19 +00:00
|
|
|
use Illuminate\Http\Request;
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
class ServerDataComposer
|
2017-09-03 02:35:33 +00:00
|
|
|
{
|
|
|
|
/**
|
2017-10-19 03:32:19 +00:00
|
|
|
* @var \Illuminate\Http\Request
|
2017-09-03 02:35:33 +00:00
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
protected $request;
|
2017-09-03 02:35:33 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-03 21:32:52 +00:00
|
|
|
* ServerDataComposer constructor.
|
2017-09-03 02:35:33 +00:00
|
|
|
*
|
2017-10-19 03:32:19 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2017-09-03 02:35:33 +00:00
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
public function __construct(Request $request)
|
2017-09-03 02:35:33 +00:00
|
|
|
{
|
2017-10-19 03:32:19 +00:00
|
|
|
$this->request = $request;
|
2017-09-03 21:32:52 +00:00
|
|
|
}
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-09-03 21:32:52 +00:00
|
|
|
/**
|
|
|
|
* Attach server data to a view automatically.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\View\View $view
|
|
|
|
*/
|
|
|
|
public function compose(View $view)
|
|
|
|
{
|
2017-10-19 03:32:19 +00:00
|
|
|
$server = $this->request->get('server');
|
2017-09-03 02:35:33 +00:00
|
|
|
|
2017-10-19 03:32:19 +00:00
|
|
|
$view->with('server', $server);
|
|
|
|
$view->with('node', object_get($server, 'node'));
|
|
|
|
$view->with('daemon_token', $this->request->get('server_token'));
|
2017-09-03 02:35:33 +00:00
|
|
|
}
|
|
|
|
}
|