misc_pterodactyl-panel/app/Http/ViewComposers/Server/ServerDataComposer.php

46 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2017-09-26 02:43:01 +00:00
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
2017-09-26 02:43:01 +00:00
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\ViewComposers\Server;
use Illuminate\View\View;
use Illuminate\Contracts\Session\Session;
class ServerDataComposer
{
/**
* @var \Illuminate\Contracts\Session\Session
*/
protected $session;
/**
* ServerDataComposer constructor.
*
* @param \Illuminate\Contracts\Session\Session $session
*/
public function __construct(Session $session)
{
$this->session = $session;
}
/**
* Attach server data to a view automatically.
*
* @param \Illuminate\View\View $view
*/
public function compose(View $view)
{
$data = $this->session->get('server_data');
$view->with('server', array_get($data, 'model'));
$view->with('node', object_get($data['model'], 'node'));
$view->with('daemon_token', array_get($data, 'token'));
}
}