Passed
Push — main ( c7a6ed...5bba20 )
by Tan
05:19
created

PostController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 16
rs 9.9
cc 1
nc 1
nop 1
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Controllers;
4
5
use CSlant\Blog\Api\Enums\StatusEnum;
6
use CSlant\Blog\Api\Http\Resources\ListPostResource;
7
use CSlant\Blog\Core\Http\Controllers\Base\BasePostController;
8
use Illuminate\Http\RedirectResponse;
9
use Illuminate\Http\Request;
10
use Illuminate\Http\Resources\Json\JsonResource;
11
12
class PostController extends BasePostController
13
{
14
    /**
15
     * @group Blog API
16
     *
17
     * @param  Request  $request
18
     *
19
     * @return \Botble\Base\Http\Responses\BaseHttpResponse|\Illuminate\Http\JsonResponse|JsonResource|RedirectResponse
0 ignored issues
show
Bug introduced by
The type Botble\Base\Http\Responses\BaseHttpResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
     */
21
    public function index(Request $request)
22
    {
23
        $data = $this->postRepository
24
            ->advancedGet([
25
                'with' => ['tags', 'categories', 'author', 'slugable'],
26
                'condition' => ['status' => StatusEnum::PUBLISHED],
27
                'paginate' => [
28
                    'per_page' => $request->integer('per_page', 10),
29
                    'current_paged' => $request->integer('page', 1),
30
                ],
31
            ]);
32
33
        return $this
34
            ->httpResponse()
35
            ->setData(ListPostResource::collection($data))
36
            ->toApiResponse();
37
    }
38
}
39