Completed
Push — master ( 002bc5...c06b9c )
by Julien
08:45
created

ApiController::actors()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 17
rs 9.4286
cc 2
eloc 9
nc 2
nop 0
1
<?php
2
3
namespace App\Http\Controllers;
4
use App\Http\Models\Actors;
5
use App\Http\Models\Categories;
6
use App\Http\Models\Comments;
7
use App\Http\Models\Movies;
8
use App\Http\Models\Sessions;
9
use App\Http\Models\User;
10
use Illuminate\Support\Facades\DB;
11
12
13
/**
14
 * Class ApiController
15
 * @package App\Http\Controllers
16
 * Sufficé par le mot clef Controller
17
 * et doit hérité de la super classe Controller
18
 */
19
class ApiController extends Controller{
20
21
22
    /**
23
     * Me retournera mes données de catégorie
24
     */
25
    public function categories(){
26
27
        $tab = [];
28
        $categories = Categories::all();
29
30
        foreach($categories as $categorie){
31
            $tab[] =
32
                [
33
                    $categorie->title,
34
                    count($categorie->movies)
35
                ];
36
        }
37
38
        return $tab;
39
40
    }
41
42
43
    /**
44
     * [{
45
    name: 'Toronto',
46
    data: [15]
47
    }, {
48
    name: 'Paris',
49
    data: [120]
50
    }, {
51
    name: 'Facebook',
52
    data: [90]
53
    }, {
54
    name: 'Dribble',
55
    data: [120]
56
    }]
57
     */
58
    public function actors(){
59
60
        $obj = new Actors();
61
        $resultat = $obj->getNbActorsByCity();
62
63
        //exit(dump($resultat));
0 ignored issues
show
Unused Code Comprehensibility introduced by
88% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
64
65
        $tab = [];
66
        foreach($resultat as $actor){
67
            $tab[] = [
68
                "name" => $actor->city,
69
                "data" => [(int)$actor->nb],
70
            ];
71
        }
72
73
        return $tab ;
74
    }
75
76
77
}
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96