/** * Execute the console command. * * @return mixed */ public function handle() { $this->info('Remove no longer used logs'); $difference = Carbon::parse("-1 months"); $logs = ApiLog::onlyTrashed()->where('deleted_at', '<', $difference)->latest()->forceDelete(); $this->info('Done!'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $date = Carbon::now()->subHours(1); $logs = ApiLog::where('created_at', '<', $date)->get(); foreach ($logs as $log) { $path = $log->images; File::delete($path); $log->delete(); } $this->info('Removed ' . count($logs) . ' Images.'); // Removed images from try service $files = Storage::allFiles("images/try"); Storage::delete($files); }
/** * Display Landingpage. * * @return Illuminate\View\View */ public function showLandingpage() { if (Auth::check()) { return redirect('/dashboard'); } else { $screenshots = \Cache::remember('global.screenshot_count', 5, function () { $result = ApiLog::select('id')->withTrashed()->latest()->first(); if ($result) { return $result->id; } return 0; }); return view('static.landingpage', compact('screenshots')); } }
/** * Close Account of logged in user. * * @return Illuminate\Http\RedirectResponse */ public function closeAccount() { $user = auth()->user(); $logs = ApiLog::where('user_id', '=', $user->id)->get(); foreach ($logs as $log) { $path = public_path(Config::get('api.storage_path') . $log->images); File::delete($path); $log->delete(); } foreach ($user->apikeys as $key) { $key->delete(); } $user->delete(); Slack::send('User deleted'); return redirect()->route('oauth.logout')->withSuccess("Youre account has been closed. Goodbye :)"); }
/** * Create ApiLog Entry * @return Screeenly\ApiLog */ public function createLogEntry() { $path = public_path($this->getFullStoragePath()); $log = new ApiLog(); $log->images = $path; if (is_null($this->key)) { $log->user_id = null; $log->api_key_id = null; } else { $log->user()->associate($this->key->user); $log->apiKey()->associate($this->key); } $log->save(); return $log; }