Example #1
0
 /**
  * Create a new instance.
  *
  * @return void
  */
 public function __construct()
 {
     //Set API base url if empty
     if (empty($this->apiBaseUrl)) {
         $this->apiBaseUrl = URL::to('/');
     }
     //Set API url if empty
     if (empty($this->apiUrl)) {
         $this->apiUrl = $this->apiBaseUrl . '/api/' . $this->apiVersion;
     }
     //Get the webste OAuth Client credentials
     $oauthClient = OauthClient::where('name', '=', 'website')->first();
     if (is_object($oauthClient)) {
         $this->clientId = $oauthClient->id;
         $this->clientSecret = $oauthClient->secret;
     }
     unset($oauthClient);
     Blade::extend(function ($view) {
         return preg_replace(array('#@translate\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@translate\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Translate::t("$1")', 'Translate::t(\'$1\')'), $view);
     });
     Blade::extend(function ($view) {
         return preg_replace(array('#@option\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@option\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Option::getAttribute(\'$1\')', 'Option::getAttribute(\'$1\')'), $view);
     });
     Blade::extend(function ($view) {
         return preg_replace(array('#@hasPermission\\(\\s*\\"([^"]+)\\"\\s*\\)#', "#@hasPermission\\(\\s*\\'([^']+)\\'\\s*\\)#"), array('Access::has(\'$1\')', 'Access::has(\'$1\')'), $view);
     });
     $this->getAccessToken();
     View::share('basePath', Request::getBaseURL());
 }