Skip to content

Commit

Permalink
Bump Inertia version from 1.3 to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
VampireAotD committed Dec 17, 2024
1 parent 27f20f1 commit fa0bbc1
Show file tree
Hide file tree
Showing 28 changed files with 883 additions and 839 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/frontend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
node-version: [ 22.x ]
pnpm-version: [ 9.14 ]
pnpm-version: [ 9.15 ]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
node-version: [ 22.x ]
pnpm-version: [ 9.14 ]
pnpm-version: [ 9.15 ]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion docker/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ARG PHP_VERSION=8.3.13
ARG COMPOSER_VERSION=2.8.3
ARG NODE_VERSION=22.11
ARG PNPM_VERSION=9.14.4
ARG PNPM_VERSION=9.15.0

FROM node:${NODE_VERSION}-alpine AS node

Expand Down
53 changes: 25 additions & 28 deletions src/app/Http/Controllers/Anime/AnimeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,23 @@ public function __construct(
*/
public function index(IndexRequest $request): Response
{
$items = $this->animeIndexService->paginate(
new AnimePaginationDTO(
page : $request->integer('page', 1),
perPage: $request->integer('perPage', 20),
filters: $request->get('filters', []),
sort : $request->get('sort', [])
)
);

$filters = $this->animeIndexService->getFacets();

return Inertia::render('Anime/Index', compact('items', 'filters'));
return Inertia::render('Anime/Index', [
'items' => Inertia::defer(fn() => $this->animeIndexService->paginate(
new AnimePaginationDTO(
page : $request->integer('page', 1),
perPage: $request->integer('perPage', 20),
filters: $request->get('filters', []),
sort : $request->get('sort', [])
)
)),
'filters' => Inertia::defer(fn() => $this->animeIndexService->getFacets()),
]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
public function create(): Response
{
$statuses = StatusEnum::values();
$genres = $this->genreService->all([new ColumnFilter(['name'])])->pluck('name')->toArray();
Expand All @@ -85,22 +84,20 @@ public function store(CreateRequest $request): RedirectResponse
*/
public function show(Request $request, Anime $anime): Response
{
$anime->load([
'image:id,path',
'urls:anime_id,url',
'synonyms:anime_id,name',
'voiceActing:name',
'genres:name',
return Inertia::render('Anime/Show', [
'anime' => $anime->load([
'image:id,path',
'urls:anime_id,url',
'synonyms:anime_id,name',
'voiceActing:name',
'genres:name',
]),
'animeListStatuses' => AnimeListStatusEnum::cases(),
'animeListEntry' => Inertia::defer(
fn() => $this->userAnimeListService->findById($request->user(), $anime->id)
),
'animeListStatistic' => Inertia::defer(fn() => $this->userAnimeListService->animeStatistics($anime->id)),
]);

$animeListEntry = $this->userAnimeListService->findById($request->user(), $anime->id);
$animeListStatuses = AnimeListStatusEnum::cases();
$animeListStatistic = $this->userAnimeListService->animeStatistics($anime->id);

return Inertia::render(
'Anime/Show',
compact('anime', 'animeListEntry', 'animeListStatuses', 'animeListStatistic')
);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function destroy(Request $request): RedirectResponse

$request->session()->regenerateToken();

Inertia::clearHistory();

return redirect('/');
}
}
14 changes: 7 additions & 7 deletions src/app/Http/Controllers/Dashboard/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
use Inertia\Inertia;
use Inertia\Response;

class DashboardController extends Controller
final class DashboardController extends Controller
{
public function __construct(private readonly AnimeService $animeService)
{
}

public function index(): Response
public function __invoke(): Response
{
$latestAnime = $this->animeService->getTenLatestAnime();
$completedAnime = $this->animeService->getTenLatestReleasedAnime();
$mostPopularAnime = $this->animeService->getTenMostPopularAnime();

return Inertia::render('Dashboard/Index', compact('latestAnime', 'completedAnime', 'mostPopularAnime'));
return Inertia::render('Dashboard/Index', [
'latestAnime' => $this->animeService->getTenLatestAnime(),
'completedAnime' => Inertia::defer(fn() => $this->animeService->getTenLatestReleasedAnime(), 'lists'),
'mostPopularAnime' => Inertia::defer(fn() => $this->animeService->getTenMostPopularAnime(), 'lists'),
]);
}
}
4 changes: 3 additions & 1 deletion src/app/Http/Controllers/Profile/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
use Inertia\Inertia;
use Inertia\Response;

class ProfileController extends Controller
final class ProfileController extends Controller
{
/**
* Display the user's profile form.
*/
public function edit(Request $request): Response
{
$request->user()->load('telegramUser:user_id,username');

return Inertia::render('Profile/Edit', [
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
'status' => session('status'),
Expand Down
2 changes: 1 addition & 1 deletion src/app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function share(Request $request): array
return [
...parent::share($request),
'auth' => [
'user' => $request->user()?->load(['roles:name', 'telegramUser:user_id,username']),
'user' => $request->user()?->load(['roles:name']),
],
'flash' => [
'message' => fn() => $request->session()->get('message'),
Expand Down
10 changes: 5 additions & 5 deletions src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"license": "BSL-1.0",
"require": {
"php": "^8.3",
"aws/aws-sdk-php": "^3.333.0",
"aws/aws-sdk-php": "^3.334.6",
"cloudinary-labs/cloudinary-laravel": "^2.2.2",
"elasticsearch/elasticsearch": "^8.16.0",
"firebase/php-jwt": "^6.10.2",
"guzzlehttp/guzzle": "^7.9.2",
"inertiajs/inertia-laravel": "^1.3.1",
"inertiajs/inertia-laravel": "^2.0.0",
"laravel/framework": "v11.34.2",
"laravel/horizon": "^5.29.4",
"laravel/horizon": "^5.30.0",
"laravel/octane": "^2.6.0",
"laravel/reverb": "^1.4.3",
"laravel/sanctum": "^4.0.5",
"laravel/reverb": "^1.4.4",
"laravel/sanctum": "^4.0.6",
"laravel/tinker": "^2.10.0",
"nutgram/laravel": "^1.4.3",
"opcodesio/log-viewer": "^3.12.0",
Expand Down
Loading

0 comments on commit fa0bbc1

Please sign in to comment.