Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Failed
Pull Request — development (#48)
by José
06:52
created

CampaignController::update()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 48
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 48
rs 9.125
cc 3
eloc 28
nc 3
nop 2
1
<?php
2
3
namespace DoeSangue\Http\Controllers\API\V1;
4
5
use DoeSangue\Http\Controllers\Controller;
6
use DoeSangue\Models\Campaign;
7
8
class CampaignController extends Controller
9
{
10
    /**
11
     * Initialize the class
12
     * and set the middleware
13
     */
14
    public function __construct()
15
    {
16
        $this->middleware('jwt.auth', [ 'except' => [ 'index', 'show' ] ]);
17
    }
18
19
    /**
20
     * Get all campaigns
21
     * 20 queries per page
22
     *
23
     * @return \Illuminate\Http\JsonResponse
24
     */
25
    public function index()
26
    {
27
        $campaigns = Campaign::with('owner')->with('comments.commentator')->paginate('12');
28
29
        return response()->json($campaigns, 200);
30
    }
31
32
    /**
33
     * Get all details of a campaign
34
     *
35
     * @param  integer $id
36
     * @return \Illuminate\Http\JsonResponse
37
     */
38
    public function show($id)
39
    {
40
        $campaign = Campaign::find($id);
41
42
        if (!$campaign) {
43
            return response()->json(
44
                [
45
                    'error_code' => 404,
46
                    'error_message' => 'Campaign not found!'
47
                ], 404
48
            );
49
        }
50
51
        return response()->json(
52
            [
53
            'title' => $campaign->title,
54
            'owner' => [
55
              'first_name' => $campaign->owner->first_name,
56
              'last_name' => $campaign->owner->last_name,
57
              'username' => $campaign->owner->username
58
            ],
59
            'dates' => [
60
            'start_at' => $campaign->created_at->format('Y-m-d h:m:s'),
61
            'finish_at' => $campaign->expires
62
            ]
63
            ], 200
64
        );
65
66
    }
67
68
}
69