← Weboldal építők adatlapja
Nézd meg, miben segít
Laravel API és Inertia
Tudatos válaszszerződéseket és takarékos Inertia-oldaladatokat készít nyers modellek kiszivárogtatása nélkül.
laravel-api-inertia
Ezt a skillt használó csapattagok
Mikor hasznos?
Akkor használd, ha Laravel-végpont vagy Inertia-oldal kiszámítható adatot és navigációt igényel.
Miben segít neked?
- Engedélyezett mezőkből és betöltött kapcsolatokból épít API Resource-ot.
- Megőrzi a státuszkódokat és lapozási metaadatokat.
- Könnyű közös oldaladatokat és mentés utáni megfelelő átirányítást ad.
Például ezt kérheted
Készíts lapozott rendeléslistát API-val és Inertia-oldallal, jogosultságfüggő mezőkkel és mentési visszajelzéssel. Ugyanazt a rendelést értékesítőként és pénzügyesként nyisd meg. A lapozott eredmény és oldaladat részleges frissítés után is csak engedélyezett mezőt tartalmazzon.
Részletes dokumentáció
Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.
Összecsukás
Laravel API & Inertia Integration
API Resources and HTTP contracts
- Transform Eloquent models through
JsonResource(ModelResource::make($model),ModelResource::collection($paginator)) rather than returning raw Eloquent models, so internal columns, hidden attributes and accidental relations never leak. - Guard every relationship and pivot attribute in
toArray()with$this->whenLoaded('relation'),$this->whenCounted('relation')and$this->whenPivotLoaded(...)so serialized resources never trigger lazy-loading N+1 queries. - Use
$this->when($condition, ...)or$this->mergeWhen(...)for role- or permission-dependent fields. - Return consistent status codes (
200,201on creation,204on empty delete,401,403,404,422for validation,409for state conflicts) and preserve pagination metadata (data,links,meta) when wrapping paginators.
Inertia.js server integration
- Render Inertia pages with
Inertia::render('Component/Name', [...])matching the project's page component conventions, passing only the fields the page needs (or wrapping models in Resources/DTOs). - Keep
HandleInertiaRequests::share()lightweight because shared props run on every request; wrap expensive or rarely needed shared data in closures so they are evaluated lazily. - Support partial reloads (
Inertia::lazy(...)/ closures) and, on Inertia v2,Inertia::defer(fn () => ...)for slow secondary panels so the initial page shell loads fast and the UI can show targeted loading skeletons. - After mutations in Inertia controllers, return a redirect (
to_route(...)orback()) with flash feedback rather than returning JSON directly, so validation errors (422->errorsprop / error bags) and Inertia'suseForm/<Form>state work seamlessly.
Csomagban lévő fájlok 2
LICENSE.txtSKILL.md
