Skip to content

Commit 7e8adea

Browse files
committed
feat: add v5 docs including supporting Laravel 12
1 parent b6e5b7f commit 7e8adea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+23652
-734
lines changed

Diff for: docs/.vitepress/5.x.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import prefix from './prefix';
2+
3+
export default (base) => [
4+
{
5+
text: 'Getting Started',
6+
collapsed: false,
7+
items: prefix(base, 'getting-started', [
8+
{text: 'Installation', link: ''},
9+
{text: 'Upgrade Guide', link: 'upgrade'},
10+
{text: 'Core Concepts', link: 'core-concepts'},
11+
{text: 'Directory Structure', link: 'directory-structure'},
12+
]),
13+
},
14+
{
15+
text: 'Tutorial',
16+
collapsed: true,
17+
items: prefix(base, 'tutorial', [
18+
{text: '1. Getting Started', link: ''},
19+
{text: '2. Models', link: '02-models'},
20+
{text: '3. Server and Schemas', link: '03-server-and-schemas'},
21+
{text: '4. Relationships', link: '04-relationships'},
22+
{text: '5. Creating Resources', link: '05-creating-resources'},
23+
{text: '6. Modifying Resources', link: '06-modifying-resources'},
24+
{text: '7. Deleting Resources', link: '07-deleting-resources'},
25+
{text: '8. Fetching Resources', link: '08-fetching-resources'},
26+
]),
27+
},
28+
{
29+
text: 'Servers',
30+
collapsed: false,
31+
items: prefix(base, 'servers', [
32+
{text: 'The Basics', link: ''},
33+
{text: 'Events', link: 'events'},
34+
]),
35+
},
36+
{
37+
text: 'Schemas',
38+
collapsed: false,
39+
items: prefix(base, 'schemas', [
40+
{text: 'The Basics', link: ''},
41+
{text: 'Identifier', link: 'identifier'},
42+
{text: 'Attributes', link: 'attributes'},
43+
{text: 'Relationships', link: 'relationships'},
44+
{text: 'Eager Loading', link: 'eager-loading'},
45+
{text: 'Sorting', link: 'sorting'},
46+
{text: 'Pagination', link: 'pagination'},
47+
{text: 'Filters', link: 'filters'},
48+
{text: 'Soft Deleting', link: 'soft-deleting'},
49+
]),
50+
},
51+
{
52+
text: 'Routing',
53+
collapsed: false,
54+
items: prefix(base, 'routing', [
55+
{text: 'Routing', link: ''},
56+
{text: 'Controllers', link: 'controllers'},
57+
{text: 'Writing Actions', link: 'writing-actions'},
58+
{text: 'Custom Actions', link: 'custom-actions'},
59+
]),
60+
},
61+
{
62+
text: 'Requests',
63+
collapsed: false,
64+
items: prefix(base, 'requests', [
65+
{text: 'The Basics', link: ''},
66+
{text: 'Authorization', link: 'authorization'},
67+
{text: 'JSON:API Compliance', link: 'compliance'},
68+
{text: 'Resources', link: 'resources'},
69+
{text: 'Query Parameters', link: 'query-parameters'},
70+
]),
71+
},
72+
{
73+
text: 'Responses',
74+
collapsed: false,
75+
items: prefix(base, 'responses', [
76+
{text: 'JSON:API Documents', link: ''},
77+
{text: 'Errors', link: 'errors'},
78+
]),
79+
},
80+
{
81+
text: 'API Resources',
82+
collapsed: true,
83+
items: prefix(base, 'resources', [
84+
{text: 'The Basics', link: ''},
85+
{text: 'Attributes', link: 'attributes'},
86+
{text: 'Relationships', link: 'relationships'},
87+
{text: 'Meta', link: 'meta'},
88+
{text: 'Links', link: 'links'},
89+
]),
90+
},
91+
{
92+
text: 'Digging Deeper',
93+
collapsed: false,
94+
items: prefix(base, 'digging-deeper', [
95+
{text: 'Artisan Console', link: 'artisan'},
96+
{text: 'Countable', link: 'countable'},
97+
{text: 'Localisation', link: 'localisation'},
98+
{text: 'Proxies', link: 'proxies'},
99+
{text: 'Non-Eloquent Models', link: 'non-eloquent'},
100+
{text: 'Polymorphic to Many', link: 'polymorphic-to-many'},
101+
]),
102+
},
103+
{
104+
text: 'Testing',
105+
collapsed: false,
106+
items: prefix(base, 'testing', [
107+
{text: 'Getting Started', link: ''},
108+
{text: 'Resources', link: 'resources'},
109+
{text: 'Relationships', link: 'relationships'},
110+
{text: 'Requests', link: 'requests'},
111+
{text: 'Assertions', link: 'assertions'},
112+
]),
113+
},
114+
];

Diff for: docs/.vitepress/config.mts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {defineConfig} from 'vitepress';
2+
import v5 from './5.x';
23
import v4 from './4.x';
34
import v3 from './3.x';
45
import v2 from './2.x';
@@ -14,6 +15,7 @@ export default defineConfig({
1415
{
1516
text: 'Version',
1617
items: [
18+
{text: '5.x', link: '/5.x/'},
1719
{text: '4.x', link: '/4.x/'},
1820
{text: '3.x', link: '/3.x/'},
1921
{text: '2.x', link: '/2.x/'},
@@ -23,6 +25,7 @@ export default defineConfig({
2325
],
2426

2527
sidebar: {
28+
'/5.x/': v5('/5.x'),
2629
'/4.x/': v4('/4.x'),
2730
'/3.x/': v3('/3.x'),
2831
'/2.x/': v2('/2.x'),
@@ -42,7 +45,7 @@ export default defineConfig({
4245

4346
footer: {
4447
message: 'Released under the MIT License.',
45-
copyright: 'Copyright © 2024 Cloud Creativity Ltd',
48+
copyright: 'Copyright © 2025 Cloud Creativity Ltd',
4649
},
4750

4851
outline: 'deep',

Diff for: docs/4.x/requests/authorization.md

-44
Original file line numberDiff line numberDiff line change
@@ -72,50 +72,6 @@ will not be allowed to perform that action. So, if you have defined a policy,
7272
don't forget to define all of its relevant authorization methods.
7373
:::
7474

75-
### Custom error messages
76-
77-
If you want to return a custom error message when a user is not authorized
78-
or based on the result of the authorization, you can use the
79-
`Illuminate\Auth\Access\Response` class. This class allows you to return a
80-
custom response when the user is not authorized or when the authorization
81-
fails.
82-
83-
For example, if you want to return a custom error message when a user is not
84-
authorized to update a post, you can use the `deny` method:
85-
86-
```php
87-
namespace App\Policies;
88-
89-
use App\Models\Post;
90-
use App\Models\User;
91-
use Illuminate\Auth\Access\Response;
92-
93-
class PostPolicy
94-
{
95-
96-
/**
97-
* Authorize a user to update a post.
98-
*
99-
* @param User $user
100-
* @param Post $post
101-
* @return Response
102-
*/
103-
public function update(User $user, Post $post): Response
104-
{
105-
if ($user->is($post->author)) {
106-
return Response::allow();
107-
}
108-
109-
return Response::deny(
110-
'You are not the author of this post. You cannot update it.'
111-
);
112-
}
113-
}
114-
```
115-
116-
This will return a `403 Forbidden` response with the custom error message
117-
when the user is not authorized to update the post.
118-
11975
### Relationship Authorization
12076

12177
Laravel JSON:API also expects policy methods to be defined for each relationship

0 commit comments

Comments
 (0)