/**
  * Bootstrap the application services.
  */
 public function boot()
 {
     parent::boot();
     $this->publishMigrations();
     $app = $this->app;
     if ($app->bound('form')) {
         $app->form->macro('selectCountry', function ($name, $selected = null, $options = []) use($app) {
             $countries = Cache::rememberForever('brianfaust.countries.select.name.cca2', function () {
                 $records = Country::get(['name', 'cca2']);
                 $countries = new Collection();
                 $records->map(function ($item) use(&$countries) {
                     $countries[$item['cca2']] = $item['name']['official'];
                 });
                 return $countries->sort();
             });
             return $app->form->select($name, $countries, $selected, $options);
         });
         $app->form->macro('selectCountryWithId', function ($name, $selected = null, $options = []) use($app) {
             $countries = Cache::rememberForever('brianfaust.countries.select.id.cca2', function () {
                 $records = Country::get(['name', 'id']);
                 $countries = new Collection();
                 $records->map(function ($item) use(&$countries) {
                     $countries[$item['id']] = $item['name']['official'];
                 });
                 return $countries->sort();
             });
             return $app->form->select($name, $countries, $selected, $options);
         });
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $makers = Cache::remember('makers', 15 / 60, function () {
         return Maker::simplePaginate(15);
     });
     return response()->json(['next' => $makers->nextPageUrl(), 'previous' => $makers->previousPageUrl(), 'data' => $makers->items()], 200);
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     if (!Cache::get('popular_categories')) {
         Cache::put('popular_categories', $this->categories->getPopular(), 60);
     }
     $view->with('popular_categories', Cache::get('popular_categories'));
 }
示例#4
0
 public function put(Route $route, Request $request, Response $response)
 {
     $key = $this->makeCacheKey($request->url());
     if (!Cache::has($key)) {
         Cache::put($key, $response->getContent(), 10);
     }
 }
示例#5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Cache::get('role.' . Auth::id()) == 'admin') {
         return $next($request);
     }
     abort(404);
 }
 /**
  * @return string
  */
 protected function getTimestampMigrationName()
 {
     if (!Cache::has(static::CACHENAME)) {
         Cache::forever(static::CACHENAME, date('Y_m_d_His') . '_' . $this->getMigrationName());
     }
     return Cache::get(static::CACHENAME);
 }
示例#7
0
 public function isAdmin()
 {
     if (Cache::has('role.' . Auth::id()) && Cache::get('role.' . Auth::id()) === 'admin') {
         return true;
     }
     return false;
 }
示例#8
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->call(function () {
         Cache::put('last-cron', new Carbon(), 5);
     })->everyMinute();
     $schedule->command('inspire')->hourly();
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $key = $this->buildCacheKey($request);
     return Cache::remember($key, static::CACHE_MINUTES, function () use($request, $next) {
         return $next($request);
     });
 }
示例#10
0
 public function update($id)
 {
     try {
         $groups = Cache::get('admin.adkats.special.groups');
         $player = Special::findOrFail($id);
         foreach ($groups as $group) {
             if ($group['group_key'] == Input::get('group')) {
                 $newGroup = $group['group_name'];
                 break;
             }
         }
         $player->player_group = Input::get('group');
         $player->save();
         if (is_null($player->player)) {
             $soldierName = $player->player_identifier;
         } else {
             $soldierName = $player->player->SoldierName;
         }
         $message = sprintf('%s group has been changed to %s.', $soldierName, $newGroup);
         return MainHelper::response(null, $message);
     } catch (ModelNotFoundException $e) {
         $message = sprintf('No player found with special id of %u', $id);
         return MainHelper::response(null, $message, 'error', 404);
     } catch (Exception $e) {
         return MainHelper::response($e, $e->getMessage(), 'error', 500);
     }
 }
示例#11
0
 private function _fetchDataset($filter)
 {
     return Cache::get($this->key, function () use($filter) {
         Cache::add($this->key, $data = $this->_getDataPartialRecursive($filter), 60);
         return $data;
     });
 }
示例#12
0
 public function restore()
 {
     //soft delete undo's
     $result = parent::restore();
     Cache::tags(Config::get('entrust.permission_role_table'))->flush();
     return $result;
 }
示例#13
0
 public function clearCache()
 {
     Cache::flush();
     Logs::add('process', "Ön Bellek Temizlendi");
     Flash::success('Ön Bellek Başarıyla Temizlendi');
     return redirect()->route('admin.index');
 }
示例#14
0
 public function restore()
 {
     //soft delete undo's
     $result = parent::restore();
     Cache::tags(Config::get('tron.role_user_table'))->flush();
     return $result;
 }
示例#15
0
 /**
  * Compose the view.
  *
  * @return void
  */
 public function compose(View $view)
 {
     $value = Cache::remember('users', 3, function () {
         return DB::table('users')->get();
     });
     $view->with('tags', Tags::all())->with('categories', Category::all());
 }
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     Feedback::created(function ($item) {
         Cache::tags('feedbacks')->flush();
         $this->dispatch(new SentenceProcessing($item));
     });
     Feedback::updated(function ($item) {
         Cache::tags('feedbacks')->flush();
     });
     Feedback::deleted(function ($item) {
         Cache::tags('feedbacks')->flush();
     });
     Comment::saved(function ($item) {
         Cache::tags('comments')->flush();
     });
     Comment::saved(function ($item) {
         Cache::tags('comments')->flush();
     });
     Sentence::saved(function ($item) {
         if ($item->feedback) {
             $item->feedback->calculateProbabilities();
         }
     });
 }
示例#17
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getClear()
 {
     // Cache::forget('settings');
     // Cache::forget('popular_categories');
     Cache::flush();
     return redirect()->back()->withSuccess('Cache Cleared!');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::user()) {
         Cache::forever('last_seen_' . Auth::user()->id, date('Y-m-d H:i:s'));
     }
     return $next($request);
 }
 public function show()
 {
     $options = Config::get('onepager.options');
     $progressBar = Cache::get('progressBar', function () {
         $c = curl_init('https://www.startnext.com/sanktionsfrei/widget/?w=200&h=300&l=de');
         curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
         $html = curl_exec($c);
         if (curl_error($c)) {
             die(curl_error($c));
         }
         $status = curl_getinfo($c, CURLINFO_HTTP_CODE);
         curl_close($c);
         $percent = 0;
         if ($status == 200) {
             $crawler = new Crawler();
             $crawler->addHTMLContent($html, 'UTF-8');
             // get the percentage for the progressbar
             $styleString = $crawler->filter('.bar.bar-1')->attr('style');
             $stringArray = explode(':', $styleString);
             $percent = substr($stringArray[1], 0, -2);
             // get the text for the progressbar
             $textArray = $crawler->filter('.status-text span')->extract(['_text']);
         }
         return ['percent' => $percent, 'progressText' => $textArray[0]];
     }, 5);
     return view('home', ['options' => $options, 'percent' => $progressBar['percent'], 'progressText' => $progressBar['progressText']]);
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $user = Cache::remember('user', 1440, function () {
         return Auth::user();
     });
     $view->with('user', $user);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $fabricantes = Cache::remember('fabricantes', 15 / 60, function () {
         return Fabricante::simplePaginate(15);
     });
     return response()->json(['siguiente' => $fabricantes->nextPageUrl(), 'anterior' => $fabricantes->previousPageUrl(), 'datos' => $fabricantes->items()], 200);
 }
示例#22
0
 public function installK2(StoreK2Request $request, MessagingResource $resource)
 {
     // TODO: this cannot be hardcoded, depends on resource type
     // Also make sure that by injecting a crafted resource id it won't be possible to override other keys!
     Cache::put("K2_SLOT_" . $resource->getResourceId(), $request->k2->toJson(), 0);
     return response(null, 204);
 }
 /**
  * Handle permissions change
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function putAll(Request $request)
 {
     $permissions = Permission::all();
     $input = array_keys($request->input('permissions'));
     try {
         DB::beginTransaction();
         $permissions->each(function ($permission) use($input) {
             if (in_array($permission->id, $input)) {
                 $permission->allow = true;
             } else {
                 $permission->allow = false;
             }
             $permission->save();
         });
         DB::commit();
         flash()->success(trans('permissions.save_success'));
     } catch (\Exception $e) {
         var_dump($e->getMessage());
         die;
         flash()->error(trans('permissions.save_error'));
     }
     try {
         Cache::tags(['permissions'])->flush();
     } catch (\Exception $e) {
         Cache::flush();
     }
     return redirect()->back();
 }
 /**
  * Setup for Google API authorization to retrieve directory data
  */
 function __construct()
 {
     // set config options
     $clientId = Config::get('google.client_id');
     $serviceAccountName = Config::get('google.service_account_name');
     $delegatedAdmin = Config::get('google.admin_email');
     $keyFile = base_path() . Config::get('google.key_file_location');
     $appName = Config::get('google.app_name');
     // array of scopes
     $scopes = array('https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.user.readonly');
     // Create AssertionCredentails object for use with Google_Client
     $creds = new \Google_Auth_AssertionCredentials($serviceAccountName, $scopes, file_get_contents($keyFile));
     // set admin identity for API requests
     $creds->sub = $delegatedAdmin;
     // Create Google_Client to allow making API calls
     $this->client = new \Google_Client();
     $this->client->setApplicationName($appName);
     $this->client->setClientId($clientId);
     $this->client->setAssertionCredentials($creds);
     if ($this->client->getAuth()->isAccessTokenExpired()) {
         $this->client->getAuth()->refreshTokenWithAssertion($creds);
     }
     Cache::forever('service_token', $this->client->getAccessToken());
     // Set instance of Directory object for making Directory API related calls
     $this->service = new \Google_Service_Directory($this->client);
 }
示例#25
0
 /**
  * Gets the latest bans
  * @param  string  $cacheKey Caching key to use
  * @param  integer $ttl      Cache for X minutes
  * @return array
  */
 public function getLatestBans($cacheKey = 'bans.latest', $ttl = 1)
 {
     $bans = Cache::remember($cacheKey, $ttl, function () {
         return Ban::with('player', 'record')->latest(30)->get()->toArray();
     });
     return $bans;
 }
示例#26
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (app()->environment() == 'local') {
         Cache::tags('views')->flush();
     }
     return $next($request);
 }
示例#27
0
 public static function boot()
 {
     parent::boot();
     Webhook::creating(function ($results) {
         Cache::forget('webhooks');
     });
 }
示例#28
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Cache::has('session.key')) {
         return redirect('/')->with('error', 'You must log in in order to view that page.');
     }
     return $next($request);
 }
示例#29
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->option('tracks') === 'all') {
         // Get all cacheable track files
         $trackFiles = TrackFile::where('is_cacheable', true)->with('track.album')->get();
     } else {
         // Get all expired track files
         $trackFiles = TrackFile::where('is_cacheable', true)->where('expires_at', '<=', Carbon::now())->with('track.album')->get();
     }
     // Delete above track files
     if (count($trackFiles) === 0) {
         $this->info('No tracks found. Exiting.');
     } else {
         if ($this->option('force') || $this->confirm(count($trackFiles) . ' cacheable track files found. Proceed to delete their files if they exist? [y|N]', false)) {
             $count = 0;
             foreach ($trackFiles as $trackFile) {
                 // Set expiration to null (so can be re-cached upon request)
                 $trackFile->expires_at = null;
                 $trackFile->update();
                 // Delete file if exists
                 if (File::exists($trackFile->getFile())) {
                     $count++;
                     File::delete($trackFile->getFile());
                     $this->info('Deleted ' . $trackFile->getFile());
                 }
                 // Remove the cached file size for the album
                 Cache::forget($trackFile->track->album->getCacheKey('filesize-' . $trackFile->format));
             }
             $this->info($count . ' files deleted. Deletion complete. Exiting.');
         } else {
             $this->info('Deletion cancelled. Exiting.');
         }
     }
 }
 /**
  * Create or update a note
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function index(Request $request)
 {
     $linehaul = $request->input('linehaul', null);
     $postalCode = $request->input('postalcode', null);
     $fresh = $request->input('fresh', false);
     $dummy = $request->input('dummy', false);
     //Damn strings
     if ($fresh == 'false') {
         $fresh = false;
     }
     if ($fresh) {
         $postalCodes = $this->getPostalCodes($linehaul, $postalCode);
     } else {
         $postalCodes = Cache::remember('postal_codes', 24 * 60, function () use($linehaul, $postalCode) {
             return $this->getPostalCodes($linehaul, $postalCode);
         });
     }
     if (!$dummy) {
         return Excel::create('PostalCodes' . Carbon::now()->toDateString(), function ($excel) use($postalCodes) {
             $excel->sheet('postalcodes', function ($sheet) use($postalCodes) {
                 $sheet->fromArray($postalCodes);
             });
         })->download('xls');
     }
     return 'DB UPDATED';
 }