Skip to content

Commit 2728103

Browse files
authored
Merge pull request #39 from Lomkit/fix/phpdoc
💡 added most php docs missing
2 parents 6effe03 + f001f1a commit 2728103

Some content is hidden

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

76 files changed

+2494
-104
lines changed

config/rest.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -83,40 +83,40 @@
8383
'url' => '/', // Relative to current
8484
'description' => 'The current server',
8585
],
86-
// [
87-
// 'url' => '"https://my-server.com:{port}/{basePath}"',
88-
// 'description' => 'Production server',
89-
// 'variables' => [
90-
// 'port' => [
91-
// 'enum' => ['80', '443'],
92-
// 'default' => '443'
93-
// ],
94-
// 'basePath' => [
95-
// 'default' => 'v2',
96-
// 'enum' => ['v1', 'v2'],
97-
// ]
98-
// ]
99-
// ]
86+
// [
87+
// 'url' => '"https://my-server.com:{port}/{basePath}"',
88+
// 'description' => 'Production server',
89+
// 'variables' => [
90+
// 'port' => [
91+
// 'enum' => ['80', '443'],
92+
// 'default' => '443'
93+
// ],
94+
// 'basePath' => [
95+
// 'default' => 'v2',
96+
// 'enum' => ['v1', 'v2'],
97+
// ]
98+
// ]
99+
// ]
100100
],
101101
// See https://spec.openapis.org/oas/v3.1.0#security-scheme-object
102102
'security' => [
103-
// [
104-
// 'type' => 'http',
105-
// 'description' => 'description',
106-
// 'scheme' => 'Bearer',
107-
// 'bearerFormat' => 'JWT'
108-
// ],
109-
// [
110-
// 'type' => 'oauth2',
111-
// 'flows' => [
112-
// 'authorizationCode' => [
113-
// 'scopes' => ['write:pets'],
114-
// 'tokenUrl' => 'https://example.com/api/oauth/token',
115-
// 'authorizationUrl' => 'https://example.com/api/oauth/dialog',
116-
// 'refreshUrl' => 'https://example.com/api/oauth/refresh',
117-
// ]
118-
// ]
119-
// ]
103+
// [
104+
// 'type' => 'http',
105+
// 'description' => 'description',
106+
// 'scheme' => 'Bearer',
107+
// 'bearerFormat' => 'JWT'
108+
// ],
109+
// [
110+
// 'type' => 'oauth2',
111+
// 'flows' => [
112+
// 'authorizationCode' => [
113+
// 'scopes' => ['write:pets'],
114+
// 'tokenUrl' => 'https://example.com/api/oauth/token',
115+
// 'authorizationUrl' => 'https://example.com/api/oauth/dialog',
116+
// 'refreshUrl' => 'https://example.com/api/oauth/refresh',
117+
// ]
118+
// ]
119+
// ]
120120
],
121121
],
122122
];

resources/views/index.blade.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,20 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />
6-
<meta
7-
name="description"
8-
content="SwaggerUI"
9-
/>
6+
<meta name="description" content="SwaggerUI" />
107
<title>SwaggerUI</title>
118
<link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" />
129
</head>
1310
<body>
14-
<div id="swagger-ui"></div>
15-
<script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js" crossorigin></script>
16-
<script>
17-
window.onload = () => {
18-
window.ui = SwaggerUIBundle({
19-
url: '/vendor/rest/openapi.json',
20-
dom_id: '#swagger-ui',
21-
});
22-
};
23-
</script>
11+
<div id="swagger-ui"></div>
12+
<script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js" crossorigin></script>
13+
<script>
14+
window.onload = () => {
15+
window.ui = SwaggerUIBundle({
16+
url: '/vendor/rest/openapi.json',
17+
dom_id: '#swagger-ui',
18+
});
19+
};
20+
</script>
2421
</body>
2522
</html>

src/Actions/Actionable.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ public function actions(RestRequest $request): array
1818
return [];
1919
}
2020

21+
/**
22+
* Check if a specific action exists.
23+
*
24+
* @param RestRequest $request
25+
* @param string $actionKey
26+
*
27+
* @return bool
28+
*/
2129
public function actionExists(RestRequest $request, string $actionKey): bool
2230
{
2331
return collect($this->actions($request))
@@ -26,6 +34,14 @@ public function actionExists(RestRequest $request, string $actionKey): bool
2634
});
2735
}
2836

37+
/**
38+
* Get a specific action instance.
39+
*
40+
* @param RestRequest $request
41+
* @param string $actionKey
42+
*
43+
* @return Action
44+
*/
2945
public function action(RestRequest $request, string $actionKey): Action
3046
{
3147
return collect($this->actions($request))

src/Concerns/PerformsRestOperations.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414

1515
trait PerformsRestOperations
1616
{
17+
/**
18+
* Retrieve details of a resource.
19+
*
20+
* @param DetailRequest $request
21+
*
22+
* @return array
23+
*/
1724
public function detail(DetailRequest $request)
1825
{
1926
$request->resource($resource = static::newResource());
@@ -25,6 +32,13 @@ public function detail(DetailRequest $request)
2532
];
2633
}
2734

35+
/**
36+
* Search for resources based on the given criteria.
37+
*
38+
* @param SearchRequest $request
39+
*
40+
* @return mixed
41+
*/
2842
public function search(SearchRequest $request)
2943
{
3044
$request->resource($resource = static::newResource());
@@ -39,6 +53,13 @@ public function search(SearchRequest $request)
3953
);
4054
}
4155

56+
/**
57+
* Mutate resources based on the given request data.
58+
*
59+
* @param MutateRequest $request
60+
*
61+
* @return mixed
62+
*/
4263
public function mutate(MutateRequest $request)
4364
{
4465
$request->resource($resource = static::newResource());
@@ -56,6 +77,14 @@ public function mutate(MutateRequest $request)
5677
return $operations;
5778
}
5879

80+
/**
81+
* Perform a specific action on the resource.
82+
*
83+
* @param OperateRequest $request
84+
* @param string $action
85+
*
86+
* @return mixed
87+
*/
5988
public function operate(OperateRequest $request, $action)
6089
{
6190
$request->resource($resource = static::newResource());
@@ -71,6 +100,13 @@ public function operate(OperateRequest $request, $action)
71100
]);
72101
}
73102

103+
/**
104+
* Delete resources based on the given request.
105+
*
106+
* @param DestroyRequest $request
107+
*
108+
* @return mixed
109+
*/
74110
public function destroy(DestroyRequest $request)
75111
{
76112
$request->resource($resource = static::newResource());
@@ -92,6 +128,13 @@ public function destroy(DestroyRequest $request)
92128
->responsable($models);
93129
}
94130

131+
/**
132+
* Restore resources based on the given request.
133+
*
134+
* @param RestoreRequest $request
135+
*
136+
* @return mixed
137+
*/
95138
public function restore(RestoreRequest $request)
96139
{
97140
$request->resource($resource = static::newResource());
@@ -114,6 +157,13 @@ public function restore(RestoreRequest $request)
114157
->responsable($models);
115158
}
116159

160+
/**
161+
* Force delete resources based on the given request.
162+
*
163+
* @param ForceDestroyRequest $request
164+
*
165+
* @return mixed
166+
*/
117167
public function forceDelete(ForceDestroyRequest $request)
118168
{
119169
$request->resource($resource = static::newResource());

src/Concerns/Relations/HasPivotFields.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,37 @@ trait HasPivotFields
77
protected array $pivotFields = [];
88
protected array $pivotRules = [];
99

10+
/**
11+
* Get the pivot fields.
12+
*
13+
* @return array
14+
*/
1015
public function getPivotFields()
1116
{
1217
return $this->pivotFields;
1318
}
1419

20+
/**
21+
* Set the pivot fields.
22+
*
23+
* @param array $pivotFields
24+
*
25+
* @return $this
26+
*/
1527
public function withPivotFields(array $pivotFields)
1628
{
1729
return tap($this, function () use ($pivotFields) {
1830
$this->pivotFields = $pivotFields;
1931
});
2032
}
2133

34+
/**
35+
* Set the pivot rules.
36+
*
37+
* @param array $pivotRules
38+
*
39+
* @return $this
40+
*/
2241
public function withPivotRules(array $pivotRules)
2342
{
2443
return tap($this, function () use ($pivotRules) {
@@ -27,6 +46,8 @@ public function withPivotRules(array $pivotRules)
2746
}
2847

2948
/**
49+
* Get the pivot rules.
50+
*
3051
* @return array
3152
*/
3253
public function getPivotRules(): array

src/Concerns/Resource/ConfiguresRestParameters.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public function fields(RestRequest $request): array
1818
return [];
1919
}
2020

21+
/**
22+
* Get nested fields by prefixing them with a given prefix.
23+
*
24+
* @param RestRequest $request
25+
* @param string $prefix
26+
* @param array $loadedRelations
27+
*
28+
* @return array
29+
*/
2130
public function getNestedFields(RestRequest $request, string $prefix = '', array $loadedRelations = [])
2231
{
2332
if ($prefix !== '') {
@@ -45,7 +54,6 @@ function ($field) use ($prefix) {
4554
// We push the pivot fields if they exists
4655
...collect(method_exists($relation, 'getPivotFields') ? $relation->getPivotFields() : [])
4756
->map(function ($field) use ($relation, $prefix) { return $prefix.$relation->relation.'.pivot.'.$field; })
48-
4957
);
5058
}
5159

src/Concerns/Resource/DisableAuthorizations.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
trait DisableAuthorizations
66
{
7+
/**
8+
* Check if authorizations are enabled.
9+
*
10+
* @return bool
11+
*/
712
public function isAuthorizingEnabled(): bool
813
{
914
return false;

src/Concerns/Resource/DisableAutomaticGates.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
trait DisableAutomaticGates
66
{
7+
/**
8+
* Check if automatic gating is enabled.
9+
*
10+
* @return bool
11+
*/
712
public function isAutomaticGatingEnabled(): bool
813
{
914
return false;

src/Concerns/Resource/Paginable.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77

88
trait Paginable
99
{
10+
/**
11+
* Paginate the results of a query.
12+
*
13+
* @param Builder $query
14+
* @param RestRequest $request
15+
*
16+
* @return mixed
17+
*/
1018
public function paginate(Builder $query, RestRequest $request)
1119
{
1220
return $query->paginate($request->input('limit', 50));

0 commit comments

Comments
 (0)