Skip to content

Commit 99b5884

Browse files
committed
fix
1 parent 5a30f21 commit 99b5884

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

docs/development/filters/define.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class MostValuableUsers extends Filter
3737
->join('licenses', 'users.id', '=', 'licenses.user_id')
3838
->orderBy('revenue', 'desc')
3939
->groupBy('users.id', 'users.name')
40+
->paginate()
4041
}
4142

4243
/**

docs/development/filters/run.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Run filter
22

3-
You can run the filter using endpoint `/{resource}/filters/{filter-name}` that allow you to run filters related to the given resource and get back result.
3+
You can run the filter using endpoint `/{resource}/filters/{filter-name}` and get back result.

docs/development/getting-started/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Carisma is designed to guarantee really great performance to suite enterprise ne
66

77
In a modern software environment RESTful web service is the **key factor** to raise your technology infrastructure and business ability to the next level. In this context Carisma was born to completely remove the highest cost when a company need to adopt this development strategy:
88

9-
> The cost of human resources needed for long months of development.
9+
> You can avoid the cost of human resources needed for loooong months of development.
1010

src/InteractWithFields.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,21 @@ trait InteractWithFields
1515
*/
1616
public function availableFields(Request $request)
1717
{
18-
return $this->resolveFields(
19-
$request, collect($this->filter($this->fields($request)))
20-
);
18+
return collect($this->filter($this->fields($request)))
19+
->reject(function ($field) use ($request) {
20+
return !$field->authorize($request);
21+
});
2122
}
2223

2324
/**
2425
* Resolve the given fields to their values.
2526
*
26-
* @param \Illuminate\Http\Request $request
2727
* @param \Illuminate\Support\Collection $fields
2828
* @return \Illuminate\Support\Collection
2929
*/
30-
protected function resolveFields(Request $request, Collection $fields)
30+
protected function resolveFields(Collection $fields)
3131
{
32-
return $fields->reject(function ($field) use ($request) {
33-
return !$field->authorize($request);
34-
})->each(function ($field) {
32+
return $fields->each(function ($field) {
3533
$field->resolve($this->resource);
3634
});
3735
}
@@ -44,7 +42,7 @@ protected function resolveFields(Request $request, Collection $fields)
4442
*/
4543
public function indexFields($request)
4644
{
47-
return $this->availableFields($request)
45+
return $this->resolveFields($this->availableFields($request))
4846
->reject(function ($field) use ($request) {
4947
return !$field->showOnIndex;
5048
});
@@ -58,7 +56,7 @@ public function indexFields($request)
5856
*/
5957
public function detailsFields($request)
6058
{
61-
return $this->availableFields($request)
59+
return $this->resolveFields($this->availableFields($request))
6260
->reject(function ($field) use ($request) {
6361
return !$field->showOnDetail;
6462
});

src/Resource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public function serializeForDetails($request)
147147
protected function timestamps()
148148
{
149149
return [
150-
DateTime::make('created_at'),
151-
DateTime::make('updated_at'),
150+
DateTime::make('created_at')->nullable(),
151+
DateTime::make('updated_at')->nullable(),
152152
];
153153
}
154154

@@ -159,6 +159,6 @@ protected function timestamps()
159159
*/
160160
protected function softDelete()
161161
{
162-
return DateTime::make('deleted_at');
162+
return DateTime::make('deleted_at')->nullable();
163163
}
164164
}

0 commit comments

Comments
 (0)