/** * @throws \Exception */ public function handle() { $name = $this->argument('name'); $isUserRestrict = $this->confirm('User restricted ?', false); $author = $this->ask("Your username", Cache::get('developer.username', '')); Cache::forever('developer.username', $author); $generator = new Generator($name, $isUserRestrict, $author); $templateData = $generator->getTemplateData(); $files = $generator->getFiles(); $belongToRelations = $this->getRelation('BelongTo'); if ($isUserRestrict) { $belongToRelations[] = 'user'; } $belongToRelations = array_unique($belongToRelations); $manyToManyRelations = $this->getRelation('ManyToMany'); $manyToManyRelations = array_unique($manyToManyRelations); $fields = $this->getFields(); $this->summary($templateData, $isUserRestrict); $this->fieldsSummary($fields); $this->generate($generator, $fields, ['belongTo' => $belongToRelations, 'manyToMany' => $manyToManyRelations]); $this->runComposerDumpAutoload(); $this->migrateDatabase(); $this->generateDocumentation(); $this->info(""); $this->info("What you need to do now ?"); $this->info("\t [] Add Acl/Scope to your route in routes.php"); $this->info("\t [] Fill data provider for " . $files['controllerTest']); $this->info("\t [] Fill data provider for " . $files['repositoryTest']); }
/** * 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); }
/** * @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); }
/** * 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); }
/** * 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]); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!Cache::has('settings')) { $settings = json_decode(Storage::get('settings.json'), true); Cache::forever('settings', $settings); } return $next($request); }
/** * 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')); }
public function cacheSetting() { $setting = self::all(); $set = []; foreach ($setting as $k => $v) { $set[$v['key']] = $v['value']; } Cache::forever('setting', $set); }
/** * Execute the console command. * * @return mixed */ public function fire() { $position = Cache::get(self::class, 0); if (!isset($this->shouts[$position])) { return; } Shout::create(['message' => $this->shouts[$position]]); Cache::forever(self::class, ++$position); }
public static function fillCacheTrans() { if (Cache::get('translations')) { $array_translate = Cache::get('translations'); } else { $array_translate = self::getArrayTranslation(); Cache::forever('translations', $array_translate); } return $array_translate; }
/** * @param $name * @return Group */ public function groupOfName($name) { $cache_key = md5('group.' . $name); if (Cache::has($cache_key)) { return Cache::get($cache_key); } $group = $this->em->getRepository($this->groupClass)->findOneBy(['lastName' => $name]); Cache::forever($cache_key, $group); return $group; }
public static function updateSideBarCache() { $categories = Category::all(); $posts = Post::orderBy('updated_at', 'desc')->limit(2)->get(); if (Cache::has('categories') || Cache::has('posts')) { Cache::flush(); } Cache::forever('posts', compact('posts')); Cache::forever('categories', compact('categories')); }
public static function getSort() { if (Cache::has(GlobalVar::$SORT_CACHE)) { return Cache::get(GlobalVar::$SORT_CACHE); } else { $sorts = Sort::all(); Cache::forever(GlobalVar::$SORT_CACHE, $sorts); return $sorts; } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function update(Request $request) { $setting = $this->settingRepository->first(); $status = $this->settingRepository->update($request->all(), $setting->id); if ($status) { Cache::forever('systemSetting', (object) $request->except('_token')); return redirect()->route('dashboard.system.setting')->with('message', trans('validation.notice.update_system_success')); } return back()->with('fail', trans('validation.notice.database_error')); }
/** * Store status in cache or print. * * @param string $status * @param bool $webExecution */ protected function writeStatus($status, $webExecution) { if ($webExecution) { $cachedStatus = unserialize(Cache::get('scaffolder-status')); array_push($cachedStatus, $status); Cache::forever('scaffolder-status', serialize($cachedStatus)); } else { $this->info($status); } }
/** * Get image from storage * * @param Request $request * @return file */ public function getImage(Request $request) { /** * Check the cache */ $cacheKey = 'image:' . $request->imageName . ':' . $request->imageExtension; /** * File cached */ if (Cache::has($cacheKey)) { $imageMeta = Cache::get($cacheKey); } else { /** * Get META information */ $imageMeta = Image::where(['url' => $request->imageName, 'image_extension' => $request->imageExtension])->first(['image_mime_type', 'image_size', 'id', 'updated_at', 'image_etag']); /** * File does not exist */ if (empty($imageMeta) == TRUE) { App::abort(404); } /** * Save meta information to cache */ Cache::forever($cacheKey, $imageMeta); } /** * Get filename */ $filename = Helpers::getStorageFilename(env('APP_IMAGE_STORAGE_DIRECTORY', 'images'), $imageMeta->id); /** * Prepare stream */ $stream = Storage::readStream($filename); /** * File headers */ $headers = array('Content-Description' => 'File Transfer', 'Content-Type' => $imageMeta->image_mime_type, 'Content-Transfer-Encoding' => 'binary', 'Pragma' => 'public', 'Expires' => Carbon::createFromTimestamp(time() + 3600)->toRfc2822String(), 'Last-Modified' => $imageMeta->updated_at->toRfc2822String(), 'Etag' => $imageMeta->image_etag); /** * Response code cached */ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $imageMeta->image_etag || isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $imageMeta->updated_at->toRfc2822String()) { $responseCode = 304; } else { $responseCode = 200; } /** * Stream to browser */ return Response::stream(function () use($stream) { fpassthru($stream); }, $responseCode, $headers); }
public function handle($request, Closure $next) { $input = $request->all(); $hash = md5(json_encode($input)); $count = Cache::get($hash, 0); if ($count > 5) { return response()->json(['result' => 'hit']); } Cache::forever($hash, $count + 1); return $next($request); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function putUpdate(Request $request) { $settings_array = $request->except('_token', '_method'); if (!in_array('enable_recaptcha', $settings_array)) { $settings_array = $settings_array + ['enable_recaptcha' => 0]; } $settings = json_encode($settings_array); Storage::put('settings.json', $settings); Cache::forever('settings', $settings_array); return redirect()->back()->withSuccess('updated'); }
/** * Set Routes * @return mixed */ public static function setRoutes() { //Get Routes $routes = false; try { $routes = Page::wherePublished("1")->get(); } catch (\Exception $e) { //Simply ignore exceptions thrown by core Laravel } Cache::forever('cmsRoutes', $routes); return $routes; }
/** * Send the response after the user was authenticated. * * @param \Illuminate\Http\Request $request * @param bool $throttles * @return \Illuminate\Http\Response */ protected function handleUserWasAuthenticated(Request $request, $throttles) { // Put menus to cache Cache::forever('menu', UserHelper::get_task_module_component('position_left_01')); if ($throttles) { $this->clearLoginAttempts($request); } if (method_exists($this, 'authenticated')) { return $this->authenticated($request, Auth::user()); } return redirect()->intended($this->redirectPath()); }
/** * 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)); }
/** * Execute the job. * */ public function handle() { if (Cache::has($this->cache_key())) { return Cache::get($this->cache_key()); } $curl = new \anlutro\cURL\cURL(); $params = ['key' => env('GOOGLE_MAP_SERVER_KEY'), 'input' => $this->location, 'language' => 'pt-BR', 'region' => 'br', 'types' => '(cities)', 'components' => 'country:BR', 'sensor' => 'false']; $url = 'https://maps.googleapis.com/maps/api/place/autocomplete/json?' . http_build_query($params); $response = $curl->get($url); $data = json_decode($response->body); Cache::forever($this->cache_key(), $data); return Cache::get($this->cache_key()); }
/** * 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)); }
/** * Execute the job. * */ public function handle() { if (Cache::has($this->cache_key())) { return Cache::get($this->cache_key()); } $curl = new \anlutro\cURL\cURL(); $params = ['key' => env('GOOGLE_MAP_SERVER_KEY'), 'address' => $this->location]; $url = 'https://maps.googleapis.com/maps/api/geocode/json?' . http_build_query($params); $response = $curl->get($url); $data = json_decode($response->body); Cache::forever($this->cache_key(), $data); return Cache::get($this->cache_key()); }
/** * Get all settings as array * * @return Array */ public static function getAll() { if (Cache::has('settings')) { $array = Cache::get('settings'); } else { $query = self::all(); $array = []; foreach ($query as $item) { $array[$item->param] = $item->value; } Cache::forever('settings', $array); } return $array; }
public static function fillCacheTrans() { if (Cache::get('translations_cms')) { $array_translate = Cache::get('translations_cms'); } else { $translations_get = DB::table("translations_phrases_cms")->leftJoin('translations_cms', 'translations_cms.id_translations_phrase', '=', 'translations_phrases_cms.id')->get(array("translate", "lang", "phrase")); $array_translate = array(); foreach ($translations_get as $el) { $array_translate[$el['phrase']][$el['lang']] = $el['translate']; } Cache::forever('translations_cms', $array_translate); } return $array_translate; }
public static function getSideBarFE() { if (Cache::has('side_bar_FE')) { $sideBar = Cache::get('side_bar_FE'); } else { $controllerType = new Type(); $controller4mat = new Format_cd(); $sideBar = $controllerType->sideBar(); $sideBar .= '<li class="sidebar-brand"><a href="#">'; $sideBar .= 'Format CD'; $sideBar .= '</a></li>'; $sideBar .= $controller4mat->sideBar(); Cache::forever('side_bar_FE', $sideBar); } return $sideBar; }
public function toggle() { $status = Cache::get('isProcessing', false); if ($status) { Cache::forever('isProcessing', false); Cache::forever('timeStarted', false); Cache::forever('timeFinished', false); return $this->respond(false); } else { Cache::forever('isProcessing', true); Cache::forever('rowsProcessedThisRun', (int) 0); Cache::forever('timeStarted', Carbon::now()); Cache::forever('timeFinished', false); return $this->respond(true); } }
/** * Handle the event. * * @param CacheEvent $event * @return void */ public function handle(CacheEvent $event) { if (!Cache::get('routes') || !Cache::get('routes_simple')) { $route_collection = Route::getRoutes(); $routes = []; foreach ($route_collection as $route) { if ($route->getName() && $route->getPrefix()) { $group = explode('@', $route->getActionName()); $routes[$route->getPrefix()][$group[0]][$route->getName()] = $route->getName(); $routes_simple[] = $route->getName(); } } Cache::forever('routes', $routes); Cache::forever('routes_simple', $routes_simple); } $this->initRoutesFormat(); }
/** * @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); }