Skip to content

Commit 99e601b

Browse files
GautierDelermunate
andcommitted
💡 added most php docs missing
Co-Authored-By: Raúl Mauricio Uñate Castro <[email protected]>
1 parent 6effe03 commit 99e601b

Some content is hidden

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

78 files changed

+2510
-441
lines changed

‎config/rest.php

+31-31
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

+11-14
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

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ 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+
* @return bool
27+
*/
2128
public function actionExists(RestRequest $request, string $actionKey): bool
2229
{
2330
return collect($this->actions($request))
@@ -26,6 +33,13 @@ public function actionExists(RestRequest $request, string $actionKey): bool
2633
});
2734
}
2835

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

‎src/Concerns/PerformsRestOperations.php

+43
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
trait PerformsRestOperations
1616
{
17+
/**
18+
* Retrieve details of a resource.
19+
*
20+
* @param DetailRequest $request
21+
* @return array
22+
*/
1723
public function detail(DetailRequest $request)
1824
{
1925
$request->resource($resource = static::newResource());
@@ -25,6 +31,12 @@ public function detail(DetailRequest $request)
2531
];
2632
}
2733

34+
/**
35+
* Search for resources based on the given criteria.
36+
*
37+
* @param SearchRequest $request
38+
* @return mixed
39+
*/
2840
public function search(SearchRequest $request)
2941
{
3042
$request->resource($resource = static::newResource());
@@ -39,6 +51,12 @@ public function search(SearchRequest $request)
3951
);
4052
}
4153

54+
/**
55+
* Mutate resources based on the given request data.
56+
*
57+
* @param MutateRequest $request
58+
* @return mixed
59+
*/
4260
public function mutate(MutateRequest $request)
4361
{
4462
$request->resource($resource = static::newResource());
@@ -56,6 +74,13 @@ public function mutate(MutateRequest $request)
5674
return $operations;
5775
}
5876

77+
/**
78+
* Perform a specific action on the resource.
79+
*
80+
* @param OperateRequest $request
81+
* @param string $action
82+
* @return mixed
83+
*/
5984
public function operate(OperateRequest $request, $action)
6085
{
6186
$request->resource($resource = static::newResource());
@@ -71,6 +96,12 @@ public function operate(OperateRequest $request, $action)
7196
]);
7297
}
7398

99+
/**
100+
* Delete resources based on the given request.
101+
*
102+
* @param DestroyRequest $request
103+
* @return mixed
104+
*/
74105
public function destroy(DestroyRequest $request)
75106
{
76107
$request->resource($resource = static::newResource());
@@ -92,6 +123,12 @@ public function destroy(DestroyRequest $request)
92123
->responsable($models);
93124
}
94125

126+
/**
127+
* Restore resources based on the given request.
128+
*
129+
* @param RestoreRequest $request
130+
* @return mixed
131+
*/
95132
public function restore(RestoreRequest $request)
96133
{
97134
$request->resource($resource = static::newResource());
@@ -114,6 +151,12 @@ public function restore(RestoreRequest $request)
114151
->responsable($models);
115152
}
116153

154+
/**
155+
* Force delete resources based on the given request.
156+
*
157+
* @param ForceDestroyRequest $request
158+
* @return mixed
159+
*/
117160
public function forceDelete(ForceDestroyRequest $request)
118161
{
119162
$request->resource($resource = static::newResource());

‎src/Concerns/Relations/HasPivotFields.php

+19
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,35 @@ 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+
* @return $this
25+
*/
1526
public function withPivotFields(array $pivotFields)
1627
{
1728
return tap($this, function () use ($pivotFields) {
1829
$this->pivotFields = $pivotFields;
1930
});
2031
}
2132

33+
/**
34+
* Set the pivot rules.
35+
*
36+
* @param array $pivotRules
37+
* @return $this
38+
*/
2239
public function withPivotRules(array $pivotRules)
2340
{
2441
return tap($this, function () use ($pivotRules) {
@@ -27,6 +44,8 @@ public function withPivotRules(array $pivotRules)
2744
}
2845

2946
/**
47+
* Get the pivot rules.
48+
*
3049
* @return array
3150
*/
3251
public function getPivotRules(): array

‎src/Concerns/Resource/ConfiguresRestParameters.php

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ 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+
* @return array
28+
*/
2129
public function getNestedFields(RestRequest $request, string $prefix = '', array $loadedRelations = [])
2230
{
2331
if ($prefix !== '') {

‎src/Concerns/Resource/DisableAuthorizations.php

+5
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

+5
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

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

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

‎src/Concerns/Resource/Relationable.php

+26
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
trait Relationable
1111
{
12+
/**
13+
* Get a relation by name.
14+
*
15+
* @param string $name
16+
* @return Relation|null
17+
*/
1218
public function relation($name)
1319
{
1420
$name = relation_without_pivot($name);
@@ -27,11 +33,25 @@ public function relation($name)
2733
return $relation;
2834
}
2935

36+
/**
37+
* Get the resource associated with a relation by name.
38+
*
39+
* @param string $name
40+
* @return Resource|null
41+
*/
3042
public function relationResource($name)
3143
{
3244
return $this->relation($name)?->resource();
3345
}
3446

47+
/**
48+
* Get nested relations with their names as keys.
49+
*
50+
* @param RestRequest $request
51+
* @param string $prefix
52+
* @param array $loadedRelations
53+
* @return array
54+
*/
3555
public function nestedRelations(RestRequest $request, string $prefix = '', array $loadedRelations = [])
3656
{
3757
if ($prefix !== '') {
@@ -68,6 +88,12 @@ public function relations(RestRequest $request): array
6888
return [];
6989
}
7090

91+
/**
92+
* Get the relations for the resource.
93+
*
94+
* @param RestRequest $request
95+
* @return array
96+
*/
7197
public function getRelations(RestRequest $request)
7298
{
7399
return array_map(function (Relation $relation) {

0 commit comments

Comments
 (0)