Skip to content

Commit

Permalink
refactor: replace View by Contracts and add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Feb 18, 2024
1 parent b095e20 commit b183725
Show file tree
Hide file tree
Showing 37 changed files with 460 additions and 143 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint files

on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: Lint files ${{ github.ref }}
cancel-in-progress: true

jobs:
php:
name: Lint PHP files
uses: monicahq/workflows/.github/workflows/lint_php.yml@v1
10 changes: 10 additions & 0 deletions .husky/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh

command_exists () {
command -v "$1" >/dev/null 2>&1
}

# Workaround for Windows 10, Git Bash, and Yarn
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/common.sh"

npx lint-staged
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use App\Providers\RouteServiceProvider;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;

class AuthenticatedSessionController extends Controller
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;

class ConfirmablePasswordController extends Controller
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;

class EmailVerificationPromptController extends Controller
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/NewPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
use Illuminate\View\View;

class NewPasswordController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/PasswordResetLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use Illuminate\View\View;

class PasswordResetLinkController extends Controller
{
Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
use App\Providers\RouteServiceProvider;
use App\Services\CreateAccount;
use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules;
use Illuminate\View\View;

class RegisteredUserController extends Controller
{
Expand All @@ -39,7 +38,7 @@ public function store(Request $request): RedirectResponse
'string',
'email',
'max:255',
Rule::unique(User::class)
Rule::unique(User::class),
],
'password' => $this->passwordRules(),
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/FavoriteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use App\Http\ViewModels\Names\NameViewModel;
use App\Http\ViewModels\User\UserViewModel;
use App\Services\ToggleNameToFavorites;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;

class FavoriteController extends Controller
{
Expand Down
22 changes: 10 additions & 12 deletions app/Http/Controllers/FemaleNameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
use App\Http\ViewModels\Names\NameViewModel;
use App\Http\ViewModels\User\UserViewModel;
use App\Models\Name;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Illuminate\View\View;

class FemaleNameController extends Controller
{
Expand All @@ -23,11 +23,10 @@ public function index(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('all-names-female-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'female')
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('all-names-female-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'female')
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand All @@ -54,12 +53,11 @@ public function letter(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('female-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'female')
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('female-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'female')
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Http\ViewModels\Home\HomeViewModel;
use App\Http\ViewModels\User\UserViewModel;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;

class HomeController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use App\Http\ViewModels\User\ListViewModel;
use App\Services\CreateList;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redirect;
use Illuminate\View\View;

class ListController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ListNameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use App\Http\ViewModels\User\ListViewModel;
use App\Services\ToggleNameToNameList;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;
use Mauricius\LaravelHtmx\Http\HtmxResponseClientRedirect;

class ListNameController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ListSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Http\ViewModels\Search\SearchViewModel;
use App\Http\ViewModels\User\ListViewModel;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;

class ListSearchController extends Controller
{
Expand Down
3 changes: 0 additions & 3 deletions app/Http/Controllers/ListSystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace App\Http\Controllers;

use App\Http\ViewModels\User\ListViewModel;
use App\Services\CreateList;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redirect;
use Illuminate\View\View;

class ListSystemController extends Controller
{
Expand Down
22 changes: 10 additions & 12 deletions app/Http/Controllers/MaleNameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
use App\Http\ViewModels\Names\NameViewModel;
use App\Http\ViewModels\User\UserViewModel;
use App\Models\Name;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Illuminate\View\View;

class MaleNameController extends Controller
{
Expand All @@ -23,11 +23,10 @@ public function index(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('all-names-male-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'male')
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('all-names-male-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'male')
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand All @@ -54,12 +53,11 @@ public function letter(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('male-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'male')
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('male-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->where('gender', 'male')
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand Down
22 changes: 10 additions & 12 deletions app/Http/Controllers/MixteNameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
use App\Http\ViewModels\Names\NameViewModel;
use App\Http\ViewModels\User\UserViewModel;
use App\Models\Name;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Illuminate\View\View;

class MixteNameController extends Controller
{
Expand All @@ -23,11 +23,10 @@ public function index(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('all-names-mixte-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->where('unisex', 1)
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('all-names-mixte-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->where('unisex', 1)
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand All @@ -54,12 +53,11 @@ public function letter(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('mixte-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->where('unisex', 1)
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('mixte-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->where('unisex', 1)
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand Down
18 changes: 8 additions & 10 deletions app/Http/Controllers/NameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use App\Http\ViewModels\User\UserViewModel;
use App\Models\Name;
use App\Services\ToggleNameToNameList;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Illuminate\View\View;

class NameController extends Controller
{
Expand All @@ -25,10 +25,9 @@ public function index(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('all-names-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('all-names-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand Down Expand Up @@ -97,11 +96,10 @@ public function letter(Request $request): View

Paginator::currentPageResolver(fn () => $requestedPage);

$namesPagination = Cache::remember('letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () =>
Name::where('name', '!=', '_PRENOMS_RARES')
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
$namesPagination = Cache::remember('letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES')
->where('name', 'like', $requestedLetter . '%')
->orderBy('total', 'desc')
->paginate(40)
);

$names = $namesPagination
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/NameFavoriteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Http\ViewModels\Names\NameViewModel;
use App\Services\ToggleNameToFavorites;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\View;

class NameFavoriteController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace App\Http\Controllers;

use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\View\View;

class ProfileController extends Controller
{
Expand Down
Loading

0 comments on commit b183725

Please sign in to comment.