Skip to content

Commit

Permalink
Remove facade dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Agontuk committed Dec 15, 2016
1 parent 03d5cb9 commit 5649c0b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
9 changes: 4 additions & 5 deletions src/Rap2hpoutre/LaravelLogViewer/LaravelLogViewer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace Rap2hpoutre\LaravelLogViewer;

use Illuminate\Support\Facades\File;
use Psr\Log\LogLevel;
use ReflectionClass;

Expand Down Expand Up @@ -48,7 +47,7 @@ public static function setFile($file)
{
$file = self::pathToLogFile($file);

if (File::exists($file)) {
if (app('files')->exists($file)) {
self::$file = $file;
}
}
Expand All @@ -57,7 +56,7 @@ public static function pathToLogFile($file)
{
$logsPath = storage_path('logs');

if (File::exists($file)) { // try the absolute path
if (app('files')->exists($file)) { // try the absolute path
return $file;
}

Expand Down Expand Up @@ -98,9 +97,9 @@ public static function all()
self::$file = $log_file[0];
}

if (File::size(self::$file) > self::MAX_FILE_SIZE) return null;
if (app('files')->size(self::$file) > self::MAX_FILE_SIZE) return null;

$file = File::get(self::$file);
$file = app('files')->get(self::$file);

preg_match_all($pattern, $file, $headings);

Expand Down
30 changes: 15 additions & 15 deletions src/controllers/LogViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ class BaseController extends \Illuminate\Routing\Controller {}
class BaseController extends \Laravel\Lumen\Routing\Controller {}
}

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Response;

class LogViewerController extends BaseController
{
protected $request;

public function __construct ()
{
$this->request = app('request');
}

public function index()
{

if (Request::input('l')) {
LaravelLogViewer::setFile(base64_decode(Request::input('l')));
if ($this->request->input('l')) {
LaravelLogViewer::setFile(base64_decode($this->request->input('l')));
}

if (Request::input('dl')) {
return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl'))));
} elseif (Request::has('del')) {
File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del'))));
return $this->redirect(Request::url());
if ($this->request->input('dl')) {
return response()->download(LaravelLogViewer::pathToLogFile(base64_decode($this->request->input('dl'))));
} elseif ($this->request->has('del')) {
app('files')->delete(LaravelLogViewer::pathToLogFile(base64_decode($this->request->input('del'))));
return $this->redirect($this->request->url());
}

$logs = LaravelLogViewer::all();

return View::make('laravel-log-viewer::log', [
return app('view')->make('laravel-log-viewer::log', [
'logs' => $logs,
'files' => LaravelLogViewer::getFiles(true),
'current_file' => LaravelLogViewer::getFileName()
Expand All @@ -45,6 +45,6 @@ private function redirect($to)
return redirect($to);
}

return Redirect::to($to);
return app('redirect')->to($to);
}
}

0 comments on commit 5649c0b

Please sign in to comment.