Esempio n. 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $load
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Setting $setting)
 {
     Cache::forget('settings');
     $setting->updateSettings($request, ['site_title', 'site_tags', 'site_description', 'allow_registration', 'pagination_num']);
     flash()->success(trans('all.entry_updated'));
     return redirect(action('Admin\\SettingsController@index'));
 }
Esempio n. 2
0
 public function render($format = 'atom', $cache = FALSE, $cacheTime = 3600)
 {
     $channel = $this->channel;
     $channel->pubdate = $this->formatDate($this->channel->pubdate, $format);
     $items = $this->items;
     foreach ($items as $item) {
         $item->pubdate = $this->formatDate($item->pubdate, $format);
     }
     if ($format == 'atom') {
         $this->content_type = 'application/atom+xml';
     } else {
         $this->content_type = 'application/rss+xml';
     }
     if ($cache == TRUE && Cache::has('feed-' . $format)) {
         return response()->view('feed::' . $format, Cache::get('feed-' . $format))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
     } elseif ($cache == TRUE) {
         Cache::put('feed-' . $format, compact('channel', 'items'), $cacheTime);
         return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
     } elseif ($cache == FALSE && Cache::has('feed-' . $format)) {
         Cache::forget('feed-' . $format);
         return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
     } else {
         return response()->view('feed::' . $format, compact('channel', 'items'))->header('Content-Type', $this->content_type)->header('Content-Type', 'text/xml');
     }
 }
Esempio n. 3
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.');
         }
     }
 }
Esempio n. 4
0
 public function unlink()
 {
     if (Cache::has($this->name)) {
         return Cache::forget($this->name);
     }
     return FALSE;
 }
Esempio n. 5
0
 public static function boot()
 {
     parent::boot();
     Webhook::creating(function ($results) {
         Cache::forget('webhooks');
     });
 }
Esempio n. 6
0
 protected function updateApproveStatus()
 {
     Cache::forget($this->qdn->slug);
     $status['status'] = $this->status() ? 'Q.a. Verification' : 'Incomplete Approval';
     $this->qdn->closure()->update($status);
     return $this;
 }
 /**
  * @inheritdoc
  */
 public function handle($arguments)
 {
     if (!Cache::has('site-' . $arguments)) {
         $this->replyWithMessage("Não foi encontrado nenhum site com esse argumento.");
         return;
     }
     $site = Cache::get('site-' . $arguments);
     // Validate if the URL isn't on the database yet
     if (Site::where('url', '=', $site)->first() != null) {
         $this->replyWithMessage("O site {$site} já se encontra na base de dados.");
         return;
     }
     $site_obj = new Site();
     $site_obj->url = $site;
     $site_obj->save();
     $this->replyWithMessage($site . " foi adicionado à base de dados.", true);
     // Notify the sitesbloqueados.pt about the new site
     $url = 'https://sitesbloqueados.pt/wp-json/ahoy/refresh';
     $cmd = "curl -X GET -H 'Content-Type: application/json'";
     $cmd .= " " . "'" . $url . "'";
     $cmd .= " > /dev/null 2>&1 &";
     exec($cmd, $output);
     // Flush the PAC cache
     Cache::tags(['generate_pac'])->flush();
     // Remove the cache
     Cache::forget('site-' . $arguments);
     Cache::forget('site-list');
 }
Esempio n. 8
0
 /**
  * Check if the api key is passed its limit, while also adding or updating cache
  * 
  * @param ApiKey $apiKey - The api key in question
  * @return boolean - Is the api key being rate limited
  */
 public static function check(\ApiKey $apiKey)
 {
     $public_key = $apiKey->public_key;
     $accessLevel = $apiKey->accessLevel;
     // check cache for the key, create is doesn't exist
     if (!Cache::has($public_key)) {
         self::generateCache($public_key, $accessLevel);
     }
     // get the cache
     $cache = json_decode(Cache::get($public_key));
     // create timestamp instances for when the cache was created and now
     $cachedTimestamp = Carbon::createFromFormat('Y-m-d H:i:s', $cache->expires_at);
     $timestamp = Carbon::now();
     // check if cache has expired, if so create cache
     if ($timestamp->gt($cachedTimestamp)) {
         Cache::forget($public_key);
         self::generateCache($public_key, $accessLevel);
         $cache = json_decode(Cache::get($public_key));
     }
     // check if api key is over request limit
     if ($cache->remaining <= 0) {
         return false;
     }
     // decrement remaining requests by 1
     $cache->remaining -= 1;
     // update cache
     Cache::put($apiKey->public_key, json_encode($cache), 0);
     return true;
 }
Esempio n. 9
0
 public function onKeysFlush()
 {
     $keys = $this->controller->getDefinitionOption('cache.keys', array());
     foreach ($keys as $key) {
         Cache::forget($key);
     }
 }
 public static function boot()
 {
     parent::boot();
     static::saved(function () {
         Cache::forget(static::HOME_CACHE_KEY);
         return true;
     });
 }
Esempio n. 11
0
 public function logout()
 {
     Cache::forget('role_id');
     Cache::forget('this_user');
     Logs::add('process', 'Kullanıcı Çıkış Yaptı');
     Auth::logout();
     return redirect()->route('master_page');
 }
 /**
  * Admin Theme Color Change
  *
  * @param   Request         $request
  * @return  \Illuminate\Http\Response
  */
 public function getThemeColorChange(Request $request)
 {
     if (Cache::has('theme_color')) {
         Cache::forget('theme_color');
     }
     Cache::forever('theme_color', $request->all());
     return response()->json(['result' => true]);
 }
Esempio n. 13
0
 public function logout()
 {
     Cache::forget('role_id');
     Cache::forget('this_user');
     Logs::add('process', trans('whole::http/controllers.auth_log_3'));
     Auth::logout();
     return redirect()->route('master_page');
 }
Esempio n. 14
0
 /**
  * bootPermissionTrait.
  *
  * @method bootPermissionTrait
  */
 public static function bootPermissionTrait()
 {
     static::saved(function ($model) {
         Cache::forget(static::cacheKey());
     }, 99);
     static::deleted(function () {
         Cache::forget(static::cacheKey());
     }, 99);
 }
Esempio n. 15
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @param Request $request
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->authorize('authorizeAccess', 'category_edit');
     $this->fieldCategory->where('id', '=', $id)->update(['name_ar' => $request->input('name_ar'), 'name_en' => $request->input('name_en')]);
     $fieldsCategories = $this->fieldCategory->all();
     Cache::forget('fieldsCategories');
     Cache::forever('fieldsCategories', $fieldsCategories);
     return redirect()->back()->with('success', trans('messages.success.updated'));
 }
Esempio n. 16
0
 /**
  * Boot the model
  * Whenever a new Webhook get's created the cache get's cleared
  */
 public static function boot()
 {
     parent::boot();
     static::created(function ($results) {
         Cache::forget(self::CACHE_KEY);
     });
     static::deleted(function ($results) {
         Cache::forget(self::CACHE_KEY);
     });
 }
Esempio n. 17
0
 /**
  * Reset cache 
  * 
  * @param object $object
  */
 public function resetCache($object)
 {
     $cacheKey = 'image:' . $object->url . ':' . $object->image_extension;
     /**
      * File cached
      */
     if (Cache::has($cacheKey)) {
         Cache::forget($cacheKey);
     }
 }
Esempio n. 18
0
 public function saveTask($id, $task)
 {
     $result = $this->fill($task)->save();
     if ($result !== FALSE) {
         //            $id = $this->
         if (Cache::has("task_{$id}")) {
             Cache::forget("task_{$id}");
         }
     }
     return $result;
 }
Esempio n. 19
0
 /**
  * Update the specified resource in storage.
  *
  * @param Request $request
  * @param  int $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     Cache::forget('settings');
     $message = $this->setting->saveData('update', $request->all(), $id) ? ['success', trans('whole::http/controllers.settings_flash_1')] : ['error', trans('whole::http/controllers.settings_flash_2')];
     Flash::$message[0]($message[1]);
     if ($message[0] == "success") {
         Logs::add('process', trans('whole::http/controllers.settings_log_1'));
     } else {
         Logs::add('errors', trans('whole::http/controllers.settings_log_2'));
     }
     return redirect()->route('admin.setting.index');
 }
Esempio n. 20
0
 public function caching($duration, $key = 'laravel-larss')
 {
     $this->cacheKey = $key;
     $this->cacheDuration = $duration;
     if (!$this->shouldCache()) {
         if ($this->isCached()) {
             Cache::forget($this->cacheKey);
         }
         return false;
     }
     return $this->isCached();
 }
Esempio n. 21
0
 /**
  * Update the specified resource in storage.
  *
  * @param Request $request
  * @param  int $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     Cache::forget('settings');
     $message = $this->setting->saveData('update', $request->all(), $id) ? ['success', 'Başarıyla Düzenlendi'] : ['error', 'Bir Hata Meydana Geldi ve Düzenlenemedi'];
     Flash::$message[0]($message[1]);
     if ($message[0] == "success") {
         Logs::add('process', "Site Ayarları Düzenlendi");
     } else {
         Logs::add('errors', "Site Ayarları Güncellenemedi!");
     }
     return redirect()->route('admin.setting.index');
 }
Esempio n. 22
0
 private function clear_articels_cache()
 {
     $pages = Redis::command('lrange', ['welcome:articles:pages', 0, -1]);
     foreach ($pages as $cache_key) {
         if (Cache::has($cache_key)) {
             Cache::forget($cache_key);
         }
     }
     Redis::command('del', ['welcome:articles:pages']);
     Cache::forget('self:rss');
     Cache::forget('self:archive');
     Cache::forget('self::categorie');
 }
 /**
  * LOGOUT A USER
  *
  * @return void
  */
 public function logOut()
 {
     try {
         ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k'));
         $session = Cache::get('sessionToken', 'default');
         $user = ParseUser::become($session);
         Cache::forget('sessionToken');
         $user->logOut();
         return Redirect::to('login');
     } catch (ParseException $error) {
         dd($error);
     }
 }
Esempio n. 24
0
 /**
  * Get settings from array
  *
  * @param array $data
  *
  * @return bool
  */
 public function insert($data = [])
 {
     foreach ($data as $key => $value) {
         // Fetch from database
         $setting = Model::where('key', '=', $key)->first();
         // Set the values
         $setting->value = $value;
         $setting->save();
         // Expire the cache
         Cache::forget($this->cacheKey);
     }
     return true;
 }
 /**
  * Handle the event.
  *
  * @param  StudentAssignmentEnded  $event
  * @return void
  */
 public function handle(StudentAssignmentEnded $event)
 {
     $assignmentId = $event->assignmentId;
     $previousUpdateId = $this->findPreviousUpdate($assignmentId);
     $assignmentUpdate = new AssignmentUpdate();
     $assignmentUpdate->assignment_id = $assignmentId;
     $assignmentUpdate->mark_book_read = true;
     $assignmentUpdate->previous_assignment_id = $previousUpdateId;
     $assignmentUpdate->save();
     Cache::forget('previous_assignment_id_for_' . $assignmentId);
     Cache::forever('previous_assignment_id_for_' . $assignmentId, $assignmentUpdate->id);
     event(new AssignmentEndedUpdateCreated($assignmentId));
 }
 /**
  * Handle the event.
  *
  * @param  StudentAssignmentUpdated  $event
  * @return void
  */
 public function handle(StudentAssignmentUpdated $event)
 {
     $assignmentId = $event->assignmentId;
     $previousUpdateId = $this->findPreviousUpdate($assignmentId);
     $assignmentUpdate = new AssignmentUpdate();
     $assignmentUpdate->assignment_id = $assignmentId;
     $assignmentUpdate->num_pages = $event->nbPages;
     $assignmentUpdate->previous_assignment_id = $previousUpdateId;
     $assignmentUpdate->save();
     Cache::forget('previous_assignment_id_for_' . $assignmentId);
     Cache::forever('previous_assignment_id_for_' . $assignmentId, $assignmentUpdate->id);
     event(new AssignmentUpdateCreated($assignmentId));
 }
 /**
  * @inheritdoc
  */
 public function handle($arguments)
 {
     if (!Cache::has('site-' . $arguments)) {
         $this->replyWithMessage("Não foi encontrado nenhum site com esse argumento.");
         return;
     }
     $site = Cache::get('site-' . $arguments);
     // Validate if the URL isn't on the database yet
     if (Cache::has('site-ignore-' . $site)) {
         $this->replyWithMessage("O site {$site} já está na lista de ignorados.");
         return;
     }
     Cache::forever('site-ignore-' . $site, 'true');
     $this->replyWithMessage($site . " será agora ignorado.", true);
     // Remove the cache
     Cache::forget('site-' . $arguments);
 }
Esempio n. 28
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $buscaren = $request->header('referer');
     $cadena = strpos($buscaren, 'atributo');
     $marcas = marcas::create($request->all());
     if ($cadena === false) {
         $refresh = 'no';
     } else {
         $refresh = 'si';
         Session::flash('mensaje', 'has creado una nueva marca');
     }
     $lista_marcas = '<option value="' . $marcas->id . '">' . $marcas->marca . '</option>';
     Cache::forget('marcas' . Session::get('tenant.id'));
     return response()->json(['marca' => $lista_marcas, 'mensaje' => 'has creado una nueva marca', 'refresh' => $refresh]);
     //
     //
 }
Esempio n. 29
0
 public static function bootEntrustRoleTrait()
 {
     static::saved(function ($item) {
         //Cache::tags(Config::get('entrust.permission_role_table'))->flush();
         Cache::forget('entrust_permissions_for_role_' . $item->getKey());
     });
     static::deleted(function ($item) {
         //Cache::tags(Config::get('entrust.permission_role_table'))->flush();
         Cache::forget('entrust_permissions_for_role_' . $item->getKey());
     });
     if (method_exists(static::class, 'restored')) {
         static::restored(function ($item) {
             //Cache::tags(Config::get('entrust.permission_role_table'))->flush();
             Cache::forget('entrust_permissions_for_role_' . $item->getKey());
         });
     }
 }
Esempio n. 30
0
 /**
  * 更新内容
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function update(Request $request, $id)
 {
     $content = Content::findOrFail($id);
     $data['title'] = $request->get('title');
     $data['seo_title'] = $request->get('seo_title');
     $data['slug'] = str_slug($request->get('slug'));
     $data['description'] = $request->get('description');
     $data['class_id'] = $request->get('class_id');
     $data['tag_id'] = $request->get('tag_id');
     $data['content'] = $request->get('content');
     $data['type'] = $request->get('type');
     $update = $content->update($data);
     if (!$update) {
         return redirect()->back();
     }
     Cache::forget('com.tanteng.share.page.' . $data['slug']);
     return redirect()->route('content.index');
 }