/**
  * Create an emoji resource
  *
  * @param Slim $app
  * @return string
  */
 public static function createEmoji(Slim $app)
 {
     $app->response->headers->set('Content-Type', 'application/json');
     $name = $app->request->params(UserController::format('name'));
     $char = $app->request->params('char');
     $keywords = $app->request->params('keywords');
     $category = $app->request->params(UserController::format('category'));
     if (!isset($name)) {
         return Errors::error401('Insert a name');
     }
     if (!isset($char)) {
         return Errors::error401('Insert an emoji');
     }
     if (!isset($keywords)) {
         return Errors::error401('Insert keywords');
     }
     if (!isset($category)) {
         return Errors::error401('Insert a category');
     }
     $passcode = Authorize::authentication($app);
     if ($passcode) {
         $emoji = new Emoji();
         $emoji->name = $name;
         $emoji->char = $char;
         $emoji->keywords = $keywords;
         $emoji->category = $category;
         $emoji->created_by = Authorize::authentication($app);
         $emoji->save();
         return json_encode(['status' => 201, 'message' => 'Your emoji was successfully created.']);
     }
 }
Beispiel #2
0
<?php

/*
 * Routes for authentication
 */
use Sirolad\app\base\controllers\UserController;
/*
 * Get register page
 */
$app->get('/register', function () use($app) {
    $app->render('register.php');
});
/*
 * Post to register page
 */
$app->post('/register', function () use($app) {
    echo UserController::register($app);
});
/*
| login
*/
$app->post('/auth/login', function () use($app) {
    echo UserController::login($app);
});
/*
| logout
*/
$app->get('/auth/logout', function () use($app) {
    echo UserController::logout($app);
});