Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
webbingbrasil/core-module / Composers / ApiAuthComposer.php
Size: Mime:
<?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;
    }
}