示例#1
1
function Check_User_Cart()
{
    $Identifier = '';
    if (!Sentry::check()) {
        return false;
    } else {
        $Identifier = Sentry::user()->id;
        if (Cookie::has('Anon_Cart_Extension')) {
            $AnonIdentifier = Cookie::get('Anon_Cart_Extension');
            $dataAnon = Cache::get('user_cart.' . $AnonIdentifier);
            if (Cache::has('user_cart.' . $Identifier)) {
                $dataUser = Cache::get('user_cart.' . $Identifier);
                if ($dataAnon != null && $dataUser != null) {
                    foreach ($dataAnon as $key => $value) {
                        if (!isset($dataUser[$key])) {
                            $dataUser[$key] = $value;
                        }
                    }
                    Cache::forever('user_cart.' . $Identifier, $dataUser);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            } else {
                if ($dataAnon != null) {
                    Cache::forever('user_cart.' . $Identifier, $dataAnon);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            }
        }
    }
}
示例#2
0
 public function testRemove()
 {
     $this->cache->set("foo", "bar");
     $this->assertEquals("bar", $this->cache->get("foo"));
     $this->cache->forget("foo");
     $this->assertNull($this->cache->get("foo"));
 }
示例#3
0
 /**
  * Removes Cache for given entity
  * @param null $entity
  */
 public function removeCache($entity = null)
 {
     if ($entity === null) {
         $entity = $this->entity;
     }
     $this->cache->forget('etag-' . $entity);
     $this->cache->forget('content-' . $entity);
 }
示例#4
0
 public static function returnRoutes($prefix = null)
 {
     $dics_for_cache = ['projects', 'types'];
     foreach ($dics_for_cache as $dic_name) {
         ## Refresh dics cache
         #Cache::forget('dic_' . $dic_name);
         $dic_[$dic_name] = Cache::get('dic_' . $dic_name);
         if (!$dic_[$dic_name]) {
             Cache::forget('dic_' . $dic_name);
             $dic_[$dic_name] = Dic::valuesBySlug($dic_name, function ($query) {
                 $query->orderBy('lft', 'ASC');
             }, ['allfields', 'alltextfields'], true, true, true);
             #Helper::d($dic_name); Helper::ta($dic_{$dic_name}); #die;
             $dic_[$dic_name] = DicLib::loadImages($dic_[$dic_name], ['avatar', 'image', 'logo', 'photo', 'header_img']);
             #Helper::d($dic_name); Helper::ta($dic_{$dic_name}); #die;
             Cache::add('dic_' . $dic_name, $dic_[$dic_name], self::$global_cache_min);
         }
         View::share('dic_' . $dic_name, $dic_[$dic_name]);
         #Helper::d($dic_name); Helper::ta($dic_{$dic_name});
     }
     #Helper::tad($dic_{'city'});
     #die;
     Route::group(array('prefix' => '{lang}'), function () {
         Route::any('/project/{slug}', array('as' => 'app.project', 'uses' => __CLASS__ . '@appProject'));
         #Route::any('/ajax/send-message', array('as' => 'ajax.send-message', 'uses' => __CLASS__.'@postSendMessage'));
         #Route::any('/ajax/some-action', array('as' => 'ajax.some-action', 'uses' => __CLASS__.'@postSomeAction'));
     });
     Route::group(array(), function () {
         #Route::any('/ajax/send-message', array('as' => 'ajax.send-message', 'uses' => __CLASS__.'@postSendMessage'));
         #Route::any('/ajax/some-action', array('as' => 'ajax.some-action', 'uses' => __CLASS__.'@postSomeAction'));
     });
 }
 public static function generateSitemap($reGenerate = false)
 {
     // create new sitemap object
     $sitemap = App::make("sitemap");
     $sitemap->setCache('laravel.sitemap', 3600);
     if ($reGenerate) {
         Cache::forget($sitemap->model->getCacheKey());
     }
     // check if there is cached sitemap and build new only if is not
     if (!$sitemap->isCached()) {
         // add item to the sitemap (url, date, priority, freq)
         $sitemap->add(URL::to('/'), null, '1.0', 'daily');
         $categories = Category::get();
         foreach ($categories as $category) {
             $sitemap->add(URL::route('category', [$category->slug]), null, '1.0', 'daily');
         }
         // get all lists from db
         $lists = ViralList::orderBy('created_at', 'desc')->get();
         // add every post to the sitemap
         foreach ($lists as $list) {
             $sitemap->add(ListHelpers::viewListUrl($list), $list->updated_at, '1.0', 'monthly');
         }
     }
     // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
     return $sitemap->render('xml');
 }
示例#6
0
 public function get_logout()
 {
     $user_id = Auth::user()->id;
     Cache::forget($user_id . 'modules');
     Auth::logout();
     return Redirect::to_action('users@login');
 }
示例#7
0
 public function update()
 {
     define('STDIN', fopen("php://stdin", "r"));
     Artisan::call("paperwork:update", ['--quiet' => true]);
     Cache::forget('paperwork.commitInfo');
     return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, array());
 }
 protected static function clearAttributeCache($model)
 {
     foreach ($model->appends as $attribute) {
         $cacheItem = get_class($model) . $model->id . $attribute;
         \Cache::forget($cacheItem);
     }
 }
 public function update($model, $input)
 {
     if ($this->cacheEnabled) {
         \Cache::forget($this->getLocaleCacheKey($model->locale));
     }
     parent::update($model, $input);
 }
 public function boot()
 {
     $postRepository = $this->app->make('App\\Repositories\\PostRepository');
     $this->app['events']->listen('user.avatar', function ($user, $image) use($postRepository) {
         if ($user->fully_started) {
             $postRepository->add(['content_type' => 'auto-post', 'type_content' => ['type' => 'change-avatar', 'avatar' => $image], 'privacy' => 1, 'type' => 'user-timeline']);
         }
     });
     $this->app['events']->listen('add-album-photos', function ($id, $photos) use($postRepository) {
         $albumRepository = $this->app->make('App\\Repositories\\PhotoAlbumRepository');
         $album = $albumRepository->get($id);
         $postRepository->add(['content_type' => 'auto-post', 'type_content' => ['type' => 'add-photos', 'photos' => $photos, 'photo-count' => count($photos), 'album' => $album], 'privacy' => 1, 'type' => 'user-timeline']);
     });
     $this->app['events']->listen('like.add', function ($userid, $type, $typeId) use($postRepository) {
         if ($type == 'page') {
             if (\Auth::check()) {
                 $page = app('App\\Repositories\\EventRepository')->get($typeId);
                 $postRepository->add(['content_type' => 'auto-post', 'type_content' => ['type' => 'like-page', 'page' => $page], 'privacy' => 1, 'type' => 'user-timeline', 'auto_like_id' => 'page-' . $page->id]);
                 \Cache::forget('page-suggestions-' . \Auth::user()->id);
             }
         } elseif ($type == 'post') {
             $post = $postRepository->findById($typeId);
             $post->touch();
             //method to update this post
             \Cache::forget('post-' . $post->id);
         }
     });
 }
 public function save($id, $request)
 {
     $notifications = $request->get('notifications');
     foreach ($notifications as $notification) {
         if ($notification['id']) {
             $model = $this->model->find($notification['id']);
             if (isset($notification['remove'])) {
                 $model->delete();
                 continue;
             }
             $model->type = $notification['type'];
             $model->data = $notification['data'];
             $model->time = $notification['time'];
             $model->msg = $notification['msg'];
             $model->save();
         } else {
             if (isset($notification['remove'])) {
                 continue;
             }
             $data = $notification + ['channel_id' => $id];
             $this->model->create($data);
         }
     }
     $key = \Config::get('site.cacheChannelsWithNotifications');
     \Cache::forget($key);
 }
 public function onDeleteRowResponse(array &$response)
 {
     $this->removeTemplate($response['values']['ident']);
     $def = $this->controller->getDefinition();
     EventsBackend::log(array('ident' => $def['db']['table'] . '_delete', 'object_table' => $def['db']['table'], 'object_id' => Input::get('id')));
     Cache::forget('settings');
 }
示例#13
0
 /**
  * Caches a model
  * 
  * @param  string   $model      The name of the model
  * @param  string   $keyPart    The key to use to cache the model (e.g. primary key)
  * @param  \App\LaravelRestCms\BaseModel $data   The model instance
  * @return string
  */
 public static function cache($model, $keyPart, $data)
 {
     $key = static::getCacheKey($model, $keyPart);
     \Cache::forget($key);
     \Cache::put($key, $data, static::$cacheTime);
     return $model;
 }
示例#14
0
 /**
  *  Clear user data in session.
  */
 function clearSession()
 {
     \Cache::forget(session()->pull('PHPSESSID'));
     session()->forget('COOKIE');
     session()->forget('courseLists');
     session()->forget('courseListsContent');
 }
示例#15
0
 /**
  * Store setting
  *
  * @param $key
  * @param $value
  * @return bool
  */
 public function set($key, $value)
 {
     /**
      * Setup cache key
      */
     $cacheKey = 'setting_' . md5($key);
     /**
      * Fetch from database
      */
     $setting = Setting::where('key', '=', $key)->first();
     /**
      * If nothing was found, create a new object
      */
     if (!is_object($setting)) {
         $setting = new Setting();
     }
     /**
      * Set the values
      */
     $setting->setKey($key)->setValue($value)->save();
     /**
      * Expire the cache
      */
     \Cache::forget($cacheKey);
     return true;
 }
 public function addNewPlace(Request $request)
 {
     $this->validate($request, ['place' => 'required']);
     $existingPlaces = json_decode(File::get(storage_path('app/places.json')), true);
     $existingPlaces[] = $request->get('place');
     File::put(storage_path('app/places.json'), json_encode($existingPlaces));
     \Cache::forget('places');
 }
示例#17
0
 protected static function boot()
 {
     parent::boot();
     static::saved(function ($model) {
         // before delete() method call this
         \Cache::forget('adminpanel_dashboard');
     });
 }
示例#18
0
 /**
  * Removes all jobs from the pool
  * 
  * @return void
  */
 public function clear()
 {
     foreach ($this->jobs as $name => $job) {
         $key = $this->makeCacheKey($name);
         $this->cache->forget($key);
     }
     $this->jobs = array();
 }
示例#19
0
 public function update(Request $request)
 {
     $this->authorize('authorizeAccess', 'contactus');
     $this->contactus->update($request->except('_token'));
     $contactInfo = $this->contactus->first();
     \Cache::forget('contactusInfo');
     \Cache::forever('contactusInfo', $contactInfo);
     return redirect()->back()->with('success', 'Contact Us Information has been updated');
 }
示例#20
0
 protected function purgeCache()
 {
     $page_count = ceil(WallPost::count() / WallPost::ITEM_PER_PAGE);
     foreach (array(0, 1) as $key) {
         for ($page_index = 0; $page_index < $page_count; $page_index++) {
             Cache::forget(sprintf('wall.%d.%d', $key, $page_index));
         }
     }
 }
 public static function deleteAppInterface($appInterfaceId)
 {
     if (Config::get('pga_config.airavata')['enable-app-catalog-cache']) {
         if (Cache::has('APP-' . $appInterfaceId)) {
             Cache::forget('APP-' . $appInterfaceId);
         }
     }
     return Airavata::deleteApplicationInterface(Session::get('authz-token'), $appInterfaceId);
 }
示例#22
0
 /**
  * Set a Config option in the Database
  * @param $key
  * @param $setting
  */
 public static function set($key, $setting)
 {
     if (Cache::has($key)) {
         Cache::forget($key);
     }
     if (self::$setQuery === null) {
         self::$setQuery = DatabaseFactory::getFactory()->getConnection()->prepare("UPDATE settings SET `value` = :setting WHERE `key` = :key");
     }
     self::$setQuery->execute(array(':key' => $key, ':setting' => $setting));
 }
示例#23
0
 public function postDelete($key_id)
 {
     $key = Key::find($key_id);
     if (empty($key)) {
         return Redirect::to('key/list')->withErrors(new MessageBag(array('Platform Key not found')));
     }
     $key->delete();
     Cache::forget('keys');
     return Redirect::to('key/list')->with('success', 'API Key deleted!');
 }
示例#24
0
 public static function boot()
 {
     parent::boot();
     static::saved(function (Lookup $lookup) {
         \Cache::forget('system_lookups');
     });
     static::deleted(function (Lookup $lookup) {
         \Cache::forget('system_lookups');
     });
 }
示例#25
0
 public static function boot()
 {
     parent::boot();
     static::created(function () {
         Cache::forget('diachi');
     });
     static::updated(function () {
         Cache::forget('diachi');
     });
 }
示例#26
0
 public function postDelete($client_id)
 {
     $client = Client::find($client_id);
     if (empty($client)) {
         return Redirect::to('client/list')->withErrors(new MessageBag(array('Client UUID not found')));
     }
     $client->modpacks()->sync(array());
     $client->delete();
     Cache::forget('clients');
     return Redirect::to('client/list')->with('success', 'Client deleted!');
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     \Cache::forget('asset_pipeline_manager');
     \Cache::forget('asset_pipeline_cached');
     $this->line('');
     $this->line('Asset pipeline cache cleared!');
     $this->line('Cache will be re-built on next page request');
     $this->line('');
     $this->line('Finished. Have a nice day! :)');
     $this->line('                          - Codesleeve Team');
 }
 /**
  * Unfollow method
  *
  * @param Model $followable
  * @return mixed
  * @throws FollowerNotFoundException
  */
 public function unfollow(Model $followable)
 {
     if ($isFollower = $this->isFollowing($followable) === true) {
         $key = $this->getFollowingCacheKey();
         if (config('lecturize.followers.cache.enable', true)) {
             \Cache::forget($key);
         }
         return Followable::following($followable)->followedBy($this)->delete();
     }
     throw new FollowerNotFoundException(get_class($this) . '::' . $this->id . ' is not following ' . get_class($followable) . '::' . $followable->id);
 }
示例#29
0
 public function action_do_delete($client_id)
 {
     $client = Client::find($client_id);
     if (empty($client)) {
         return Redirect::back();
     }
     $client->modpacks()->delete();
     $client->delete();
     Cache::forget('clients');
     return Redirect::to('client/list')->with('success', 'Client deleted!');
 }
示例#30
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $users = User::all();
     foreach ($users as $k => $user) {
         $used = \Cache::get("requests:users:{$user->id}");
         if (!is_null($used) && $used > 0) {
             $user->requests_left -= $used;
             $user->save();
             \Cache::forget("requests:users:{$user->id}");
         }
     }
 }