/** * */ public function __call($method, $params) { if (!method_exists($this->repository, $method)) { throw new RepositoryException("Method {$method} not found on repository"); } if ($this->skipCache === true || config('laravel-database.cache') === false) { return call_user_func_array(array($this->repository, $method), $params); } else { if (empty($this->key)) { $this->cacheKey($this->generateKey($method, $params)); } $key = $this->key; unset($this->key); if ($this->refreshCache) { $this->cache->forget($key); $this->refreshCache = false; } if (empty($this->lifetime)) { $this->cacheLifetime($this->repository->getModel()->cacheLifetime()); } $lifetime = $this->lifetime; unset($this->lifetime); return $this->cache->remember($key, $lifetime, function () use($method, $params) { return call_user_func_array(array($this->repository, $method), $params); }); } }
/** * Override startup of the Shell * * @return void */ public function startup() { parent::startup(); if (isset($this->params['connection'])) { $this->connection = $this->params['connection']; } $class = Configure::read('Acl.classname'); list($plugin, $class) = pluginSplit($class, true); App::uses($class, $plugin . 'Controller/Component/Acl'); if (!in_array($class, array('DbAcl', 'DB_ACL')) && !is_subclass_of($class, 'DbAcl')) { $out = "--------------------------------------------------\n"; $out .= __d('cake_console', 'Error: Your current Cake configuration is set to an ACL implementation other than DB.') . "\n"; $out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n"; $out .= "--------------------------------------------------\n"; $out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n"; $out .= "--------------------------------------------------\n"; $this->err($out); $this->_stop(); } if ($this->command) { if (!config('database')) { $this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true); $this->args = null; return $this->DbConfig->execute(); } require_once APP . 'Config' . DS . 'database.php'; if (!in_array($this->command, array('initdb'))) { $collection = new ComponentCollection(); $this->Acl = new AclComponent($collection); $controller = new Controller(); $this->Acl->startup($controller); } } }
/** * */ public function boot() { $this->app->singleton('moip-client', function () { return new MoipClient(config('moip-assinaturas.api_token'), config('moip-assinaturas.api_key'), config('moip-assinaturas.environment', 'api')); }); $this->app->singleton('moip-api', function () { return new Api(app('moip-client')); }); $this->app->bind('moip-plans', function () { return app('moip-api')->plans(); }); $this->app->bind('moip-subscriptions', function () { return app('moip-api')->subscriptions(); }); $this->app->bind('moip-customers', function () { return app('moip-api')->customers(); }); $this->app->bind('moip-invoices', function () { return app('moip-api')->invoices(); }); $this->app->bind('moip-preferences', function () { return app('moip-api')->preferences(); }); $this->app->bind('moip-payments', function () { return app('moip-api')->payments(); }); $this->publishes([__DIR__ . '/../../../config/config.php' => config_path('moip-assinaturas.php')]); }
/** * Build the qiniu image url with the specified key * @param $key * @return null|string */ public static function buildQiqiuImageUrl($key) { if (is_null($key)) { return null; } return config('quickcms.qiniu_url') . '/' . $key; }
/** * @param string $model The model to list. * @return mixed */ public function index(Request $request, $model) { if (!Auth::check()) { return response("Unauthorised", 401); } $user = Auth::user(); if ($user->cannot('administrate')) { return response("Unauthorised", 401); } $class = $this->getModel($model); if (is_null($class)) { return response("No items found for this model {$model}", 404); } $pagination_enabled = config('crudapi.pagination.enabled'); $perPage = config('crudapi.pagination.perPage'); if ($pagination_enabled) { $items = $class->paginate($perPage); } else { $items = $class->all(); } $fields = $class->getFillable(); $data = $this->buildData(); $data['items'] = $items; $data['model'] = $model; $data['fields'] = $fields; $data['uiframework'] = config('crudapi.framework', 'bs3'); $data['timestamps'] = config('crudapi.admin.showTimestamps', false); $data['show_ids'] = config('crudapi.admin.showIds', false); return view('crudapi::admin.index', $data); }
protected function failedValidation(Validator $validator) { if (config('app.debug') || Request::is("api/*")) { throw new ValidationException($validator); } return parent::failedValidation($validator); }
/** * Execute the console command. * * @return mixed */ public function handle() { // Add the TransLaravel service provider $this->info('Publishing assets...'); $this->info(\Artisan::call('vendor:publish')); //, ['--provider' => 'deArgonauten/TransLaravel\TransLaravelServiceProvider', '--force' => true]); $this->info('Done!'); // Do the migrations $this->info('Migrating translations...'); $this->info(\Artisan::call('migrate', ['--path' => 'vendor/deArgonauten/TransLaravel/src/migrations', '--force' => true])); $this->info('Done!'); $fallback_locale = config('app.fallback_locale'); $locale = config('app.locale'); if (!$this->confirm('Is ' . $fallback_locale . ' the correct fallback locale? [y|N]')) { $this->info('Please correct the config in config/app.php.'); if (!$this->confirm('Did you correct te locale? [y|N]')) { $this->info('Quite stubborn, eh? We will proceed.'); } } // Install middleware. $this->addServiceProvider(); if ($this->confirm('Do you want to have your routes translated? [y|N]')) { // Install middleware. $this->addMiddleware(); } $this->info('All done!'); }
public function __construct() { $this->middleware('ipblocked'); $driver = config('database.default'); $database = config('database.connections'); $this->db = $database[$driver]['database']; $this->dbuser = $database[$driver]['username']; $this->dbpass = $database[$driver]['password']; $this->dbhost = $database[$driver]['host']; if (\Auth::check() == true) { if (!\Session::get('gid')) { \Session::put('uid', \Auth::user()->id); \Session::put('gid', \Auth::user()->group_id); \Session::put('eid', \Auth::user()->email); \Session::put('ll', \Auth::user()->last_login); \Session::put('fid', \Auth::user()->first_name . ' ' . \Auth::user()->last_name); \Session::put('themes', 'sximo-light-blue'); } } if (!\Session::get('themes')) { \Session::put('themes', 'sximo'); } if (defined('CNF_MULTILANG') && CNF_MULTILANG == 1) { $lang = \Session::get('lang') != "" ? \Session::get('lang') : CNF_LANG; \App::setLocale($lang); } $data = array('last_activity' => strtotime(Carbon::now())); \DB::table('tb_users')->where('id', \Session::get('uid'))->update($data); }
/** * Register the service provider. * * @return void */ public function register() { $this->app->bind('Usman\\Guardian\\Repositories\\Interfaces\\RoleRepositoryInterface', function () { $role = config('guardian.roleModel'); return new RoleRepository(new $role()); }); }
public function __construct() { $request = App::make(\Illuminate\Http\Request::class); $this->middleware('web'); $this->middleware('auth.role:admin'); $this->setupTheme(config('theme.themes.user.theme'), config('theme.themes.user.layout')); }
public function register() { $this->app->bind('googleSearch', function () { $googlesearchConfig = config('googleSearch'); return new GoogleSearch($googlesearchConfig['searchEngineId']); }); }
public function index(Request $request) { $parameters = $request->route()->parameters(); $parser = new Parser($parameters); $generator = new Generator($request->path()); if (!isset($parameters['version']) && !isset($parameters['resource']) && !isset($parameters['action'])) { $segments = ['index']; } else { $segments = $parameters; } $file = base_path('resources/' . config('apidocu.base') . '/' . implode('/', $segments) . '.md'); if (file_exists($file)) { $content = file_get_contents($file); $status = 200; } else { $status = 404; switch (config('apidocu.404.type')) { case 'text': $content = config('apidocu.404.value'); break; case 'view': $content = view(config('apidocu.404.value')); break; default: $content = '**404 - page not found**'; break; } } $content = $parser->parse($content); return Response::make(view('apidocu::index')->with(['navigation' => $generator->navigation(), 'breadcrumb' => $generator->breadcrumb(), 'content' => $content]), $status); }
/** * Register service provider. * * @return void */ public function register() { $this->mergeConfigFrom(__DIR__ . '/config.php', 'geography'); // Http switch (config('geography.services.http.implementation')) { case 'Guzzle': $this->app->bind('Maxyc\\Laravel\\Geography\\Services\\Http\\HttpInterface', 'Maxyc\\Laravel\\Geography\\Services\\Http\\GuzzleHttp'); break; } $this->app->bind('http', 'Maxyc\\Laravel\\Geography\\Services\\Http\\HttpInterface'); // Countries switch (config('geography.services.countries.implementation')) { case 'Geonames': $this->app->bind('Maxyc\\Laravel\\Geography\\Services\\Countries\\CountriesInterface', 'Maxyc\\Laravel\\Geography\\Services\\Countries\\GeonamesCountries'); break; } $this->app->bind('countries', 'Maxyc\\Laravel\\Geography\\Services\\Countries\\CountriesInterface'); // Location switch (config('geography.services.location.implementation')) { case 'Telize': $this->app->bind('Maxyc\\Laravel\\Geography\\Services\\Location\\LocationInterface', 'Maxyc\\Laravel\\Geography\\Services\\Location\\TelizeLocation'); break; case 'Ipapi': $this->app->bind('Maxyc\\Laravel\\Geography\\Services\\Location\\LocationInterface', 'Maxyc\\Laravel\\Geography\\Services\\Location\\IpapiLocation'); break; } $this->app->bind('location', 'Maxyc\\Laravel\\Geography\\Services\\Location\\LocationInterface'); // Phones switch (config('geography.services.phones.implementation')) { case 'Restcountries': $this->app->bind('Maxyc\\Laravel\\Geography\\Services\\Phones\\PhonesInterface', 'Maxyc\\Laravel\\Geography\\Services\\Phones\\RestcountriesPhones'); break; } $this->app->bind('phones', 'Maxyc\\Laravel\\Geography\\Services\\Phones\\PhonesInterface'); }
/** * Define the routes for the application. * * @param \Illuminate\Routing\Router $router * * @return void */ public function map(Router $router) { $router->group(['namespace' => $this->namespace], function (Router $router) { /* * Front office routes */ if ($page = TypiCMS::getPageLinkedToModule('galleries')) { $options = $page->private ? ['middleware' => 'auth'] : []; foreach (config('translatable.locales') as $lang) { if ($page->translate($lang)->status && ($uri = $page->uri($lang))) { $router->get($uri, $options + ['as' => $lang . '.galleries', 'uses' => 'PublicController@index']); $router->get($uri . '/{slug}', $options + ['as' => $lang . '.galleries.slug', 'uses' => 'PublicController@show']); } } } /* * Admin routes */ $router->get('admin/galleries', 'AdminController@index')->name('admin::index-galleries'); $router->get('admin/galleries/create', 'AdminController@create')->name('admin::create-gallery'); $router->get('admin/galleries/{gallery}/edit', 'AdminController@edit')->name('admin::edit-gallery'); $router->post('admin/galleries', 'AdminController@store')->name('admin::store-gallery'); $router->put('admin/galleries/{gallery}', 'AdminController@update')->name('admin::update-gallery'); /* * API routes */ $router->get('api/galleries', 'ApiController@index')->name('api::index-galleries'); $router->put('api/galleries/{gallery}', 'ApiController@update')->name('api::update-gallery'); $router->delete('api/galleries/{gallery}', 'ApiController@destroy')->name('api::destroy-gallery'); }); }
/** * Process password forgotten * * @access public * @return void */ public function process() { $email_address = $this->input->post('email_address'); if (validate_email_address($email_address)) { //load model $this->load->model('account_model'); $data = $this->account_model->get_data($email_address); if ($data !== NULL) { $password = create_random_string(config('ACCOUNT_PASSWORD')); if ($this->account_model->save_password($data['customers_id'], $password)) { $this->load->library('email_template'); $email = $this->email_template->get_email_template('password_forgotten'); $email->set_data($data['customers_firstname'], $data['customers_lastname'], getenv('REMOTE_ADDR'), $password, $data['customers_gender'], $data['customers_email_address']); $email->build_message(); $email->send_email(); $this->message_stack->add_session('login', lang('success_password_forgotten_sent'), 'success'); redirect('account/login'); } } else { $this->message_stack->add('password_forgotten', lang('error_password_forgotten_no_email_address_found')); } } else { $this->message_stack->add('password_forgotten', lang('error_password_forgotten_no_email_address_found')); } $this->template->build('account/password_forgotten'); }
/** * Retrieve the models primary field for display purposes. * * @param $item Model to retrieve primary field of * @param null|array $config CrudApi Configuration * * @return string */ public function getPrimaryField($item, $config = null) { /* If config is not overridden then load crudapi config */ if ($config === null) { $config = config('crudapi'); } if (!isset($config['models']['fields']['default'])) { $defaultField = 'name'; } else { $defaultField = $config['models']['fields']['default']; } /* Get the items Class */ $class = get_class($item); $stripped_class = str_replace($this->crudApi->namespace, '', $class); // if class starts with a \ remove it. if (substr($stripped_class, 0, 1) == '\\') { $stripped_class = substr($stripped_class, 1); } $primaryFields = $config['models']['fields']['primary']; if (array_key_exists($stripped_class, $primaryFields)) { return $primaryFields[$stripped_class]; } else { //return the default return $defaultField; } }
/** * Instantiate a new instance * * @return void */ public function __construct() { $this->username = config('whmcs.username'); $this->password = config('whmcs.password'); $this->response_type = strtolower(config('whmcs.response_type')); $this->client = new Client(['base_uri' => config('whmcs.url'), 'timeout' => config('whmcs.timeout'), 'headers' => ['Accept' => 'application/json']]); }
/** * Construct the IPBoard API package. * * @return void */ public function __construct() { $this->url = config("ipboard.api_url"); $this->key = config("ipboard.api_key"); $this->reference = config("ipboard.api_reference_name"); $this->httpRequest = new HttpClient(["base_uri" => $this->url, "timeout" => 2.0, "defaults" => ["auth" => [$this->key, ""]], "auth" => [$this->key, ""]]); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $currencies = join(',', array_keys(config('base.currencies'))); $term_types = join(',', array_keys(config('base.term_types'))); $movement_types = join(',', array_keys(config('base.movement_types'))); return ['coverage' => 'required|exists:ad_coverages,id', 'amount_requested' => 'required|numeric|min:1', 'currency' => 'required|in:' . $currencies, 'term' => 'required|integer|min:1', 'type_term' => 'required|in:' . $term_types, 'credit_product' => 'required|exists:ad_credit_products,id', 'movement_type' => 'required|in:' . $movement_types]; }
/** * Register the service provider. * * @return void */ public function register() { $this->app['sms'] = $this->app->share(function ($app) { $config = config('sms'); return new Sms($config, new SoapClient($config['webserviceUrl'])); }); }
/** * Загрузка конфигурационных файлов из БД с заменой ключей */ public function boot() { $config = DatabaseConfig::get(); foreach ($config as $group => $data) { app('config')->set($group, array_merge(config($group, []), $data)); } }
function __construct() { $this->sender = "*****@*****.**"; $this->defaultTo = "*****@*****.**"; $this->mailSenderLink = 'http://localhost:3000/mail'; $this->siteName = config('app_site_name'); }
public function __construct($name) { $this->name = $name; $this->themePath = config('themer.themes_path'); $this->themeExists($name); // check right away. It'll throw an exception when it exists }
public function boot() { if (!$this->files->exists(app_path() . '/Modules/')) { mkdir(app_path() . '/Modules/'); } $modules = config("modules.list") ?: array_map('class_basename', $this->files->directories(app_path() . '/Modules/')); foreach ($modules as $module) { $routes = app_path() . '/Modules/' . $module . '/Http/routes.php'; $views = app_path() . '/Modules/' . $module . '/Views'; $trans = app_path() . '/Modules/' . $module . '/Translations'; if ($this->files->exists($routes)) { include $routes; } if ($this->files->isDirectory($views)) { $this->loadViewsFrom($views, $module); } if ($this->files->isDirectory($trans)) { $this->loadTranslationsFrom($trans, $module); } //load multiple config files inside config folder $config_files = array_map('class_basename', $this->files->files(app_path() . '/Modules/' . $module . '/config/')); foreach ($config_files as $config_file) { $fname = basename($config_file, ".php"); $this->mergeConfigFrom(app_path() . '/Modules/' . $module . '/config/' . $config_file, 'mod-' . $fname); } } }
/** * Register the service provider. * * @return void */ public function register() { $this->app->bindShared('tevo', function () { return new Client(config('ticketevolution')); }); $this->app->alias('tevo', 'TicketEvolution\\Client'); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if (config('app.debug') === false) { return $this->handleExceptions($e); } return parent::render($request, $e); }
function input($key, $data, $view = 'default') { //$input = parent::inputSelect($key,null,self::$val,false,'class="gender"'); if (isset($data->wysiwyg) && $data->wysiwyg == true) { $controller = ''; $script = 'jQuery("textarea.tinymce[name=' . self::protection($key) . ']").tinymce({' . 'imageDIR:encodeURI("' . config('resource_domain') . "/jquery/elfinder-2.0/php/connector.php?dir={$controller}" . '")' . '});'; $this->CI->template->add_js_ready($script); } // $script=''; //if($contentOnly==true) return "<div class='row' style='width:100%;'><textarea id='$fieldKey' name='".self::$protection."$fieldKey' class='tinymce' style='width:100%; ' >$fieldData</textarea></div>"; $input = '<textarea name="' . self::protection($key) . '" class="tinymce">' . $data->value . '</textarea>'; $classAdded = isset($data->addclass) && $data->addclass ? $data->addclass : null; if (isset($data->view) && $data->view == 'input' || $view == 'input') { return parent::rowFormInput('<textarea name="' . self::protection($key) . '" class="tinymce ' . $classAdded . '" style=" width:100%; " >' . $data->value . '</textarea>'); } if ($view == 'val') { return self::$val[$data->value]; } else { if ($view == 'input') { return $input; } else { return self::rowForm($data->title, $input); } } }
public function route($original_url, $default_controller = 'default', $default_action = 'index') { $this->url = $original_url; $url = $this->resolve($original_url); $request = $this->request($url, $default_controller, $default_action); try { $controller = new $request['class']($original_url); $controller->url = $original_url; if (!method_exists($controller, $request['action'])) { return $this->error404(); } $content = call_user_func_array(array($controller, $request['action']), $request['params']); } catch (AutoloadException $e) { //debug($e); return $this->error404($e->getMessage()); } // We also show a 404 page when controller method returns false if ($content === false) { return $this->error404(); } // Wrap in template $data = empty($controller->layoutData) ? array() : $controller->layoutData; $data['title'] = empty($controller->title) ? (string) config()->site->title : $controller->title; $data['description'] = empty($controller->description) ? (string) config()->site->description : $controller->description; $data['url'] = $original_url; $data['content'] = $content; return $controller->applyLayout($data); }
function testVerify() { // Given $this->startSession(); $userData = ['name' => 'Some name', 'email' => '*****@*****.**', 'password' => 'strongpassword', 'country_code' => '1', 'phone_number' => '5558180101']; $user = new User($userData); $user->authy_id = 'authy_id'; $user->save(); $this->be($user); $mockAuthyApi = Mockery::mock('Authy\\AuthyApi')->makePartial(); $mockVerification = Mockery::mock(); $mockTwilioClient = Mockery::mock(\Twilio\Rest\Client::class)->makePartial(); $mockTwilioClient->messages = Mockery::mock(); $twilioNumber = config('services.twilio')['number']; $mockTwilioClient->messages->shouldReceive('create')->with($user->fullNumber(), ['body' => 'You did it! Signup complete :)', 'from' => $twilioNumber])->once(); $mockAuthyApi->shouldReceive('verifyToken')->with($user->authy_id, 'authy_token')->once()->andReturn($mockVerification); $mockVerification->shouldReceive('ok')->once()->andReturn(true); $this->app->instance(\Twilio\Rest\Client::class, $mockTwilioClient); $this->app->instance('Authy\\AuthyApi', $mockAuthyApi); $modifiedUser = User::first(); $this->assertFalse($modifiedUser->verified); // When $response = $this->call('POST', route('user-verify'), ['token' => 'authy_token', '_token' => csrf_token()]); // Then $modifiedUser = User::first(); $this->assertRedirectedToRoute('user-index'); $this->assertTrue($modifiedUser->verified); }
/** * Run the database seeds. * * @return void */ public function run() { $statuses = config('webegg.statuses'); foreach ($statuses as $k => $v) { \App\Status::create(['name' => $k, 'style' => $v]); } }