Test Failed
Push — master ( baab8c...6507f4 )
by Maximo
01:50
created

api/routes/api.php (1 issue)

1
<?php
0 ignored issues
show
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
use Baka\Http\RouterCollection;
4
5
/*
6
|--------------------------------------------------------------------------
7
| API Routes
8
|--------------------------------------------------------------------------
9
|
10
| Here is where you can register all of the routes for api.
11
 */
12
13
$router = new RouterCollection($application);
14
$router->setPrefix('/v1');
15
$router->get('/', [
16
    'Gewaer\Api\Controllers\IndexController',
17
    'index',
18
]);
19
20
$router->get('/status', [
21
    'Gewaer\Api\Controllers\IndexController',
22
    'status',
23
]);
24
25
/**
26
 * Authentification Calls
27
 * @var [type]
28
 */
29
$router->post('/auth', [
30
    'Gewaer\Api\Controllers\AuthController',
31
    'login',
32
]);
33
34
//asociate mobile devices
35
$router->post('/users/{id}/devices', [
36
    'Gewaer\Api\Controllers\UsersController',
37
    'devices',
38
]);
39
40
/**
41
 * Need to understand if using this can be a performance disadvantage in the future
42
 */
43
$defaultCrudRoutes = [
44
    'users',
45
    'companies',
46
];
47
48
foreach ($defaultCrudRoutes as $key => $route) {
49
    //set the controller name
50
    $name = is_int($key) ? $route : $key;
51
    $controllerName = ucfirst($name) . 'Controller';
52
53
    $router->get('/' . $route, [
54
        'Gewaer\Api\Controllers\\' . $controllerName,
55
        'index',
56
    ]);
57
58
    $router->post('/' . $route, [
59
        'Gewaer\Api\Controllers\\' . $controllerName,
60
        'create',
61
    ]);
62
63
    $router->get('/' . $route . '/{id}', [
64
        'Gewaer\Api\Controllers\\' . $controllerName,
65
        'getById',
66
    ]);
67
68
    $router->put('/' . $route . '/{id}', [
69
        'Gewaer\Api\Controllers\\' . $controllerName,
70
        'edit',
71
    ]);
72
73
    $router->put('/' . $route, [
74
        'Gewaer\Api\Controllers\\' . $controllerName,
75
        'multipleUpdates',
76
    ]);
77
78
    $router->delete('/' . $route . '/{id}', [
79
        'Gewaer\Api\Controllers\\' . $controllerName,
80
        'delete',
81
    ]);
82
}
83
84
$router->post('/users', [
85
    'Gewaer\Api\Controllers\AuthController',
86
    'signup',
87
]);
88
89
$router->mount();
90