Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
KABBOUCHI authored and StyleCIBot committed Feb 20, 2019
1 parent 173f476 commit f1103d6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 65 deletions.
72 changes: 37 additions & 35 deletions src/Http/Controllers/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace KABBOUCHI\LogsTool\Http\Controllers;

use KABBOUCHI\Ward\Ward;
use Illuminate\Http\Request;
use KABBOUCHI\LogsTool\LogsTool;
use KABBOUCHI\Ward\Ward;
use Illuminate\Routing\Controller;
use Illuminate\Pagination\LengthAwarePaginator;

Expand Down Expand Up @@ -42,38 +42,40 @@ public function dailyLogFiles()
});
}

/**
* @param $log
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
* @throws \Exception
*/
public function show($log,Request $request)
{
if (!LogsTool::authorizedToDownload($request))
abort(403);

return response()->download(Ward::pathToLogFile($log));
}

/**
* @param Request $request
* @throws \Exception
*/
public function destroy(Request $request)
{
if (!LogsTool::authorizedToDelete($request))
abort(403);

app('files')->delete(Ward::pathToLogFile(request('file')));
cache()->clear();
}

public function permissions(Request $request)
{
return [
'canDownload' => LogsTool::authorizedToDownload($request),
'canDelete' => LogsTool::authorizedToDelete($request),
];
}
/**
* @param $log
* @param Request $request
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
* @throws \Exception
*/
public function show($log, Request $request)
{
if (! LogsTool::authorizedToDownload($request)) {
abort(403);
}

return response()->download(Ward::pathToLogFile($log));
}

/**
* @param Request $request
* @throws \Exception
*/
public function destroy(Request $request)
{
if (! LogsTool::authorizedToDelete($request)) {
abort(403);
}

app('files')->delete(Ward::pathToLogFile(request('file')));
cache()->clear();
}

public function permissions(Request $request)
{
return [
'canDownload' => LogsTool::authorizedToDownload($request),
'canDelete' => LogsTool::authorizedToDelete($request),
];
}
}
59 changes: 29 additions & 30 deletions src/LogsTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace KABBOUCHI\LogsTool;

use Illuminate\Http\Request;
use Laravel\Nova\Nova;
use Illuminate\Http\Request;
use Laravel\Nova\Tool as BaseTool;

class LogsTool extends BaseTool
{
protected static $downloadCallback = null;
protected static $deleteCallback = null;
protected static $downloadCallback = null;
protected static $deleteCallback = null;

/**
* Perform any tasks that need to happen when the tool is booted.
Expand All @@ -32,36 +32,35 @@ public function renderNavigation()
return view('LogsTool::navigation');
}

public static function authorizedToDownload(Request $request)
{
return static::$downloadCallback ? call_user_func(static::$downloadCallback, $request) : true;
}

public static function authorizedToDelete(Request $request)
{
return static::$deleteCallback ? call_user_func(static::$deleteCallback, $request) : true;
}
public static function authorizedToDownload(Request $request)
{
return static::$downloadCallback ? call_user_func(static::$downloadCallback, $request) : true;
}

public static function authorizedToDelete(Request $request)
{
return static::$deleteCallback ? call_user_func(static::$deleteCallback, $request) : true;
}

/**
* @param \Closure $closure
* @return $this
*/
public function canDownload(\Closure $closure)
{
self::$downloadCallback = $closure;
/**
* @param \Closure $closure
* @return $this
*/
public function canDownload(\Closure $closure)
{
self::$downloadCallback = $closure;

return $this;
}
return $this;
}

/**
* @param \Closure $closure
* @return $this
*/
public function canDelete(\Closure $closure)
{
self::$deleteCallback = $closure;
/**
* @param \Closure $closure
* @return $this
*/
public function canDelete(\Closure $closure)
{
self::$deleteCallback = $closure;

return $this;
}
return $this;
}
}

0 comments on commit f1103d6

Please sign in to comment.