示例#1
0
<?php

$app->get('/problemas', 'auth', function () use($app) {
    $model = new models\Problem();
    $problemas = $model->getAll();
    $app->render('problems/index.html', ['problemas' => $problemas]);
});
$app->get('/problemas/novo', 'auth', function () use($app) {
    $client = new models\Client();
    $clientes = $client->getAll();
    $category = new models\Category();
    $categorias = $category->getAll('titulo', 'ASC');
    $app->render('problems/form.html', ['clientes' => $clientes, 'categorias' => $categorias]);
});
$app->post('/problemas/novo', 'auth', function () use($app) {
    $data = $app->request()->post();
    $helpers = new lib\Helpers();
    $data['cliente_id'] = $data['cliente_id'];
    $data['categoria_id'] = $data['categoria_id'];
    $data['data_hora'] = $helpers->dateTimeDB($data['data'], $data['hora']);
    unset($data['data']);
    unset($data['hora']);
    unset($data['_wysihtml5_mode']);
    $data['usuario_id'] = $_SESSION['user']['id'];
    $problem = new models\Problem();
    $problem->insert($data);
    $app->redirect($app->url . '/problemas');
});
$app->post('/problemas/:id/editar', 'auth', function ($id) use($app) {
    $data = $app->request()->post();
    $data['id'] = $id;
示例#2
0
<?php

// GET index route
$app->get('/', 'auth', function () use($app) {
    $problem = new models\Problem();
    $topic = new models\Topic();
    $client = new models\Client();
    $programmer = new models\Programmer();
    $count['problemas'] = $problem->count();
    $count['topicos'] = $topic->count();
    $count['clientes'] = $client->count();
    $count['programadores'] = $programmer->count();
    $problemas = $problem->get(10);
    $topicos = $topic->get(10);
    $app->render('index.html', ['count' => $count, 'problemas' => $problemas, 'topicos' => $topicos]);
});
示例#3
0
<?php

$app->get('/clientes/modal/novo', 'auth', function () use($app) {
    $app->render('clients/modal.html');
});
$app->post('/clientes/modal/novo', 'auth', function () use($app) {
    $data = $app->request()->post();
    $client = new models\Client();
    $client->insert($data);
});
$app->get('/clientes/select', 'auth', function () use($app) {
    $model = new models\Client();
    $clientes = $model->getAll('nome', 'ASC');
    $last = $model->get();
    $app->render('clients/select.html', ['clientes' => $clientes, 'id' => $last[0]['id']]);
});