Repository URL to install this package:
|
Version:
1.0.0 ▾
|
<?php namespace Modules\Core\Composers;
use Illuminate\Contracts\View\View;
use Modules\Core\Entities\ApiToken;
class ApiAuthComposer
{
/**
* @param View $view
*/
public function compose(View $view)
{
$view->with('apiauth', $this->getApiAuthKey());
}
/**
* Add the html of the widget view to the given widget name
* @param string $name
* @param string $view
* @return $this
*/
public function getApiAuthKey()
{
$defaultToken = ApiToken::find(1);
$html = '<script>';
$html .= 'apiServices.apiURI = "' . url()->to('/api') . '/";';
$html .= 'apiServices.apiKey = "' . $defaultToken->token . '";';
$html .= 'apiServices.init();';
$html .= '</script>';
return $html;
}
}