Skip to content

Commit

Permalink
Merge pull request #1 from KABBOUCHI/analysis-qBZwrO
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
KABBOUCHI authored Aug 23, 2018
2 parents 9a43e5f + 2e3e21c commit 6decea2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 36 deletions.
1 change: 0 additions & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
Expand Down
16 changes: 9 additions & 7 deletions src/Http/Controllers/ApiController.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php namespace KABBOUCHI\LogsTool\Http\Controllers;
<?php

namespace KABBOUCHI\LogsTool\Http\Controllers;

use Illuminate\Http\Response;

abstract class ApiController
abstract class ApiController
{
public function respondSuccess(): Response
{
return response('', Response::HTTP_NO_CONTENT);
}
}
public function respondSuccess(): Response
{
return response('', Response::HTTP_NO_CONTENT);
}
}
47 changes: 24 additions & 23 deletions src/Http/Controllers/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,41 @@

namespace KABBOUCHI\LogsTool\Http\Controllers;

use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Routing\Controller;
use KABBOUCHI\Ward\Ward;
use Illuminate\Routing\Controller;
use Illuminate\Pagination\LengthAwarePaginator;

class LogsController extends Controller
{
public function index()
{
Ward::setFile($file = request()->input('file', 'laravel.log'));
public function index()
{
Ward::setFile($file = request()->input('file', 'laravel.log'));

$logs = Ward::all();
$logs = Ward::all();

$currentPage = LengthAwarePaginator::resolveCurrentPage();
$currentPage = LengthAwarePaginator::resolveCurrentPage();

$collection = collect($logs);
$collection = collect($logs);

$search = request()->input('search');
$search = request()->input('search');

if ($search)
$collection = $collection->filter(function ($log) use ($search) {
return false !== stristr($log['text'], $search);
});
if ($search) {
$collection = $collection->filter(function ($log) use ($search) {
return false !== stristr($log['text'], $search);
});
}

$perPage = 6;
$perPage = 6;

$currentPageSearchResults = $collection->slice(($currentPage - 1) * $perPage, $perPage)->values()->toArray();
$currentPageSearchResults = $collection->slice(($currentPage - 1) * $perPage, $perPage)->values()->toArray();

return new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage);
}
return new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage);
}

public function dailyLogFiles()
{
return collect(Ward::getFiles(true))->filter(function ($file) {
return strpos($file, 'laravel') === 0;
});
}
public function dailyLogFiles()
{
return collect(Ward::getFiles(true))->filter(function ($file) {
return strpos($file, 'laravel') === 0;
});
}
}
2 changes: 1 addition & 1 deletion src/Http/Middleware/Authorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public function handle(Request $request, Closure $next): Response
? $next($request)
: abort(403);
}
}
}
4 changes: 0 additions & 4 deletions tests/ToolControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace KABBOUCHI\LogsTool\Tests;

use KABBOUCHI\LogsTool\Http\Controllers\LogsController;
use KABBOUCHI\LogsTool\LogsTool;
use Symfony\Component\HttpFoundation\Response;

class ToolControllerTest extends TestCase
{
/** @test */
Expand Down

0 comments on commit 6decea2

Please sign in to comment.