menu

Syntax - Syntax elasticsearch


Pada tutorial kali ini, codedoct akan sharing syntax2 untuk elasticsearch, apa itu elasticsearch? bisa cari tahu di official websitenya langsung disini,

Untuk mengetesnya bisa menggunakan postman yang diinstall pada chrome,
Oke langsung saja sharing ilmu.

Test elasticsearch

Add index

Get index

Add document

Get document

Search Document

Show Document

Bulk Document

Edit document

Delete document

Delete index


===DONE!===

Laravel - RESTful project (API delete data)


Pada tutorial kali ini kita akan membuat sebuah engine REST-ful untuk delete data, sebagai lanjutan tutorial yang sebelumnya.

Sama seperti tutorial sebelumnya untuk dapat melakukan delete data user maka kita harus melempar parameter ID data user yang akan didelete.

Oke langsung saja kita mulai experimentnya,
Pertama, tambahkan route baru untuk method baru delete ini dengan mengedit code pada file route api.php yang terletak pada path protected/app/routes/ edit menjadi seperti ini,
<?php 

//////////
// CRUD //
//////////
//pahamilah group route dibawah
Route::group(array('prefix' => 'crud'), function(){
 Route::get('users', 'Controller\Api\UserController@getUsers');
 Route::post('store-user', 'Controller\Api\UserController@storeUser');
 Route::get('{id}', 'Controller\Api\UserController@showUser');
 Route::patch('{id}', 'Controller\Api\UserController@updateUser');
 Route::delete('{id}', 'Controller\Api\UserController@deleteUser');
});

Selanjutnya, edit file UserController.php pada path protected/app/controllers/api/ menjadi seperti ini,
<?php namespace Controller\Api;

use Model\User;
use \Response;
use \Validator;
use \Input;
use Illuminate\Http\Request;


class UserController extends \BaseController 
{
 public function getUsers()
 {
  $users = User::get();

  $response['status'] = 'OK';
  $response['result'] = $users;

  return Response::json($response);
 }

 public function storeUser()
 {
  $validator = Validator::make(
   Input::all(),
   array(
    "name"     => "required",
    "username"    => "required|unique:users,username",
    "email"     => "required|email|unique:users,email",
       "password"              => "required|min:6",
   )
  );
  // dd($_POST);
  if ($validator->passes()) {
      $user = User::storeOrUpdateUser(Input::all(), null);
      // dd($_POST);
      $response['status'] = 'OK';
      $response['result'] = $user;
     }
     else {
      $response['status'] = 'ERROR';
      $response['message'] = $validator->messages();
     }

  return Response::json($response);
 }

 public function showUser($id)
 {
  $user = User::find($id);

  if ($user) {
   $response['status'] = 'OK';
   $response['result'] = $user;
  } else {
   $response['status'] = 'ERROR';
   $response['message'] = 'User not found';
  }

  return Response::json($response);
 }

 public function updateUser($id)
 {
  $validator = Validator::make(
   Input::all(),
   array(
    "name"     => "required",
    "username"    => "required|unique:users,username,".$id,
    "email"     => "required|email|unique:users,email,".$id,
       "password"              => "required|min:6",
   )
  );

  $user = User::find($id); 
  
  if ($user) {
   if ($validator->passes()) {
       $user = User::storeOrUpdateUser(Input::all(), $user);
       $response['status'] = 'OK';
       $response['result'] = $user;
      }
      else {
       $response['status'] = 'ERROR';
       $response['message'] = $validator->messages();
      }
  } else {
   $response['status'] = 'ERROR';
      $response['message'] = 'User not found';
  }

  return Response::json($response);
 }

 public function deleteUser($id)
 {
  $user = User::find($id);

  if ($user) {
   $user->delete();
   $response['status'] = 'OK';
   $response['result'] = 'Success delete user';
  } else {
   $response['status'] = 'ERROR';
   $response['message'] = 'User not found';
  }

  return Response::json($response);
 }
}

Terakhir, test pada postman jika ID user ditemukan maka proses delete user berhasil,



Jika ID user tidak ditemukan maka akan muncul error seperti ini,



===DONE!===

Laravel - RESTful project (API update data)



Pada tutorial sebelumnya kita sudah membuat API untuk show data, tutorial kali ini kita akan meneruskan sistem RESTful membuat API update data. Pada API ini kita akan melemparkan parameter ID yang mrupakan ID data yang akan di edit datanya.

Oke langsung saja kita mulai experimentnya,
Pertama, buat terlebih dahulu route APInya dengan cara edit file api.php pada path protected/app/routes/ menjadi seperti ini,
<?php 

//////////
// CRUD //
//////////
//pahamilah group route dibawah
Route::group(array('prefix' => 'crud'), function(){
 Route::get('users', 'Controller\Api\UserController@getUsers');
 Route::post('store-user', 'Controller\Api\UserController@storeUser');
 Route::get('{id}', 'Controller\Api\UserController@showUser');
 Route::patch('{id}', 'Controller\Api\UserController@updateUser');
});
Dapat dilihat pada code diatas, RESTful untuk update data menggunakan method PATCH.

Selanjutnya, buat method untuk update atau edit dengan cara edit file UserController.php pada path protected/app/controllers/api/ menjadi seperti ini,
<?php namespace Controller\Api;

use Model\User;
use \Response;
use \Validator;
use \Input;
use Illuminate\Http\Request;


class UserController extends \BaseController 
{
 public function getUsers()
 {
  $users = User::get();

  $response['status'] = 'OK';
  $response['result'] = $users;

  return Response::json($response);
 }

 public function storeUser()
 {
  $validator = Validator::make(
   Input::all(),
   array(
    "name"     => "required",
    "username"    => "required|unique:users,username",
    "email"     => "required|email|unique:users,email",
       "password"              => "required|min:6",
   )
  );
  // dd($_POST);
  if ($validator->passes()) {
      $user = User::storeOrUpdateUser(Input::all(), null);
      // dd($_POST);
      $response['status'] = 'OK';
      $response['result'] = $user;
     }
     else {
      $response['status'] = 'ERROR';
      $response['message'] = $validator->messages();
     }

  return Response::json($response);
 }

 public function showUser($id)
 {
  $user = User::find($id);

  if ($user) {
   $response['status'] = 'OK';
   $response['result'] = $user;
  } else {
   $response['status'] = 'ERROR';
   $response['message'] = 'User not found';
  }

  return Response::json($response);
 }

 public function updateUser($id)
 {
  $validator = Validator::make(
   Input::all(),
   array(
    "name"     => "required",
    "username"    => "required|unique:users,username,".$id,
    "email"     => "required|email|unique:users,email,".$id,
       "password"              => "required|min:6",
   )
  );

  $user = User::find($id); 

  if ($user) {
   if ($validator->passes()) {
       $user = User::storeOrUpdateUser(Input::all(), $user);
       $response['status'] = 'OK';
       $response['result'] = $user;
      }
      else {
       $response['status'] = 'ERROR';
       $response['message'] = $validator->messages();
      }
  } else {
   $response['status'] = 'ERROR';
      $response['message'] = 'User not found';
  }

  return Response::json($response);
 }
}

Kemudian, kita test dengan menggunakan postman dengan memasukan url dan method seperti pada gambar dibawah ini,


Terakhir masukan parameter yang akan kita edit datanya seperti pada gambar dibawah,
Dapat dilihat pada gambar diatas, body yang kita lempar menggunakan postman menggunakan format x-www-form-urlencoded bukan form-data seperti pada API store data, hal ini dikarenakan kita menggunakan method PATCH yang tidak support menggunakan format form-data.

Sehingga hasilnya akan tampak seperti pada gambar dibawah ini,



===DONE!===

Laravel - RESTful project (API show data)


Tutorial sebelumnya kita sudah membuat RESTful untuk store data, pada tutorial kali ini kita akan membuat RESTful sistem untuk menampilkan data berdasarkan ID yang ingin ditampilkan.

Oke, langsung saja kita mulai experimentnya,
Pertama, buat dulu route yang akan mengarah pada API show data dengan mengedit file api.php pada path protected/app/routes/ menjadi seperti ini,
<?php 

//////////
// CRUD //
//////////
//pahamilah group route dibawah
Route::group(array('prefix' => 'crud'), function(){
 Route::get('users', 'Controller\Api\UserController@getUsers');
 Route::post('store-user', 'Controller\Api\UserController@storeUser');
 Route::get('{id}', 'Controller\Api\UserController@showUser');
});

Selanjutnya, buat method baru yang akan mengarahkan pada url show data tersebut dengan mengedit file UserController.php pada path protected/app/controllers/api/ menjadi seperti ini,
<?php namespace Controller\Api;

use Model\User;
use \Response;
use \Validator;
use \Input;
use Illuminate\Http\Request;


class UserController extends \BaseController 
{
 public function getUsers()
 {
  $users = User::get();

  $response['status'] = 'OK';
  $response['result'] = $users;

  return Response::json($response);
 }

 public function storeUser()
 {
  $validator = Validator::make(
   Input::all(),
   array(
    "name"     => "required",
    "username"    => "required|unique:users,username",
    "email"     => "required|email|unique:users,email",
       "password"              => "required|min:6",
   )
  );
  // dd($_POST);
  if ($validator->passes()) {
      $user = User::storeOrUpdateUser(Input::all(), null);
      // dd($_POST);
      $response['status'] = 'OK';
      $response['result'] = $user;
     }
     else {
      $response['status'] = 'ERROR';
      $response['message'] = $validator->messages();
     }

  return Response::json($response);
 }

 public function showUser($id)
 {
  $user = User::find($id);

  if ($user) {
   $response['status'] = 'OK';
   $response['result'] = $user;
  } else {
   $response['status'] = 'ERROR';
   $response['message'] = 'User not found';
  }

  return Response::json($response);
 }
}

Kemudian testing dengan Postman masukan url seperti pada gambar dibawah dan dengan method GET, jangan lupa untuk mengganti "http://localhost:2305/BLOG/" sesuaikan dengan url lokal komputer anda,


Sehingga saat di Send hasilnya akan tampak seperti ini,



===DONE!===

Phalcon - CRUD (Delete)


Akhirnya sampai juga pada tutorial terakhir sistem CRUD Phalcon, pada tutorial terakhir ini kita akan membuat feature delete yang akan digunakan untuk menghapus data user pada database

Oke langsung saja kita mulai tutorialnya,
Pertama, buat terlebih dahulu routenya dengan mengedit file router.php pada path app/config/ menjadi seperti ini,
<?php

$router = $di->getRouter();

// Define your routes here
/**
 * Get user lists data by query
 */
$router->addGet(
    "/user",
    [
        "controller"        => "user",
        "action"            => "index"
    ]
);
$router->addGet(
    "/user/{userId}",
    [
        "controller"        => "user",
        "action"            => "show"
    ]
);
$router->addGet(
    "/user/create",
    [
        "controller"        => "user",
        "action"            => "create"
    ]
);
$router->addPost(
    "/user/create",
    [
        "controller"        => "user",
        "action"            => "save"
    ]
);
$router->addDelete(
    "/user/delete/{userId}",
    [
        "controller"        => "user",
        "action"            => "delete"
    ]
);
$router->addPut(
    "/user/edit/{userId}",
    [
        "controller"        => "user",
        "action"            => "edit"
    ]
);

$router->addGet(
    "/test",
    [
        "controller"        => "test",
        "action"            => "test"
    ]
);

$router->handle();

Selanjutnya, buat method delete dengan mengedit file UserController.php pada path app/controllers/ menjadi seperti ini,
<?php

class UserController extends ControllerBase
{
    public function indexAction()
    {
     $users = Users::find();
     $this->view->title = "Phalcon - Users";
     $this->view->users = $users;
     // dd($users);
    }

    public function showAction($userId)
    {
     $conditions = ['userId'=>$userId];
     $user = Users::findFirst([
      'conditions' => 'id=:userId:',
      'bind' => $conditions,
  ]);
     $this->view->title = "Phalcon - User";
     $this->view->user = $user;
     // dd($users);
    }

    public function createAction()
    {
        $this->view->title = "Phalcon - Create user";
    }

    public function saveAction()
    {
        $name = $this->request->get('name');
        $email = $this->request->get('email');
        $address = $this->request->get('address');

        $user = new Users();
        $user->name = $name;
        $user->email = $email;
        $user->address = $address;

        if ($this->request->isPost()) {
            if ($user->create()) {
                return $this->response->redirect('user');
            }
        } else {
            $this->flash->error('User form is not valid.');
        }
    }

    public function deleteAction($userId)
    {
        $conditions = ['userId'=>$userId];
        $user = Users::findFirst([
            'conditions' => 'id=:userId:',
            'bind' => $conditions,
        ]);
        if ($user->delete() === false) {
            $messages = $user->getMessages();
            foreach ($messages as $message) {
                $this->flash->error($message);
            }
        } else {
            return $this->response->redirect('user');
        }
    }

    public function editAction($userId)
    {
        $conditions = ['userId'=>$userId];
        $user = Users::findFirst([
            'conditions' => 'id=:userId:',
            'bind' => $conditions,
        ]);
        $this->view->title = "Phalcon - User";
        $this->view->user = $user;

        if ($this->request->isPost()) {
            $name = $this->request->get('name');
            $email = $this->request->get('email');
            $address = $this->request->get('address');

            $user->name = $name;
            $user->email = $email;
            $user->address = $address;

            if ($user->save()) {
                return $this->response->redirect('user');
            } else {
                $messages = $user->getMessages();
                foreach ($messages as $message) {
                    $this->flash->error($message);
                }
            }
        }
    }
}

Terakhir buat button atau link untuk menghapus data pada view index dengan mengedit file index.volt pada path app/views/user/ menjadi seperti ini,
{% extends 'layouts/default1.volt' %}

{% block content %}
 <br/>
 Hello codedoct!!!
 <br><br>
 <div class="row">
  <div class="col-md-12">
   user list:
   <br><br>
   <table width="100%">
    <tr>
     <th>Name</th>
     <th>Action</th>
    </tr>
    {% for user in users %}
     <tr>
      <td>{{ user.name }}</td>
      <td><a href="user/{{ user.id }}">show</a> || <a href="user/edit/{{ user.id }}">edit</a> || <a href="user/delete/{{ user.id }}">delete</a></td>
     </tr>
    {% endfor %}
   </table>
   <br>
   <button onclick="window.location.href='user/create'">Create</button>
  </div>
 </div>
{% endblock %}

Sehingga tampilan halaman utamanya akan tampak seperti ini,


===DONE!===

Phalcon - CRUD (Update)


Pada tutorial kemarin kita sudah membuat feature untuk menambahkan data user pada database, tutorial kali kita akan membuat feature untuk mengedit data user pada database

Oke kita mulai saja experimentnya,
Pertama, buat terlebih dahulu routenya dengan cara mengedit file router.php pada path app/config/ edit menjadi seperti ini,
<?php

$router = $di->getRouter();

// Define your routes here
/**
 * Get user lists data by query
 */
$router->addGet(
    "/user",
    [
        "controller"        => "user",
        "action"            => "index"
    ]
);
$router->addGet(
    "/user/{userId}",
    [
        "controller"        => "user",
        "action"            => "show"
    ]
);
$router->addGet(
    "/user/create",
    [
        "controller"        => "user",
        "action"            => "create"
    ]
);
$router->addPost(
    "/user/create",
    [
        "controller"        => "user",
        "action"            => "save"
    ]
);
$router->addPut(
    "/user/edit/{userId}",
    [
        "controller"        => "user",
        "action"            => "edit"
    ]
);

$router->addGet(
    "/test",
    [
        "controller"        => "test",
        "action"            => "test"
    ]
);

$router->handle();

Selanjutnya, tambahkan method baru pada controller dengan cara mengedit file UserController.php pada path app/controllers/ edit menjadi seperti ini,
<?php

class UserController extends ControllerBase
{
    public function indexAction()
    {
     $users = Users::find();
     $this->view->title = "Phalcon - Users";
     $this->view->users = $users;
     // dd($users);
    }

    public function showAction($userId)
    {
     $conditions = ['userId'=>$userId];
     $user = Users::findFirst([
      'conditions' => 'id=:userId:',
      'bind' => $conditions,
  ]);
     $this->view->title = "Phalcon - User";
     $this->view->user = $user;
     // dd($users);
    }

    public function createAction()
    {
        $this->view->title = "Phalcon - Create user";
    }

    public function saveAction()
    {
        $name = $this->request->get('name');
        $email = $this->request->get('email');
        $address = $this->request->get('address');

        $user = new Users();
        $user->name = $name;
        $user->email = $email;
        $user->address = $address;

        if ($this->request->isPost()) {
            if ($user->create()) {
                return $this->response->redirect('user');
            }
        } else {
            $this->flash->error('User form is not valid.');
        }
    }

    public function editAction($userId)
    {
        $conditions = ['userId'=>$userId];
        $user = Users::findFirst([
            'conditions' => 'id=:userId:',
            'bind' => $conditions,
        ]);
        $this->view->title = "Phalcon - User";
        $this->view->user = $user;

        if ($this->request->isPost()) {
            $name = $this->request->get('name');
            $email = $this->request->get('email');
            $address = $this->request->get('address');

            $user->name = $name;
            $user->email = $email;
            $user->address = $address;

            if ($user->save()) {
                return $this->response->redirect('user');
            } else {
                $messages = $user->getMessages();
                foreach ($messages as $message) {
                    $this->flash->error($message);
                }
            }
        }
    }
}

Kemudian, buat file view baru dengan nama edit.volt pada path app/views/user/ dan isikan code berikut,
{% extends 'layouts/default1.volt' %}

{% block content %}
 <br/>
 Hello codedoct!!!
 <br><br>
 <div class="row">
  <div class="col-md-12">
   <form method="POST">
    <div class="form-group">
     <label>Nama user</label>
     <input type="text" name="name" class="form-control" placeholder="Type your name" required value="{{ user.name }}">
    </div>
    <div class="form-group">
     <label>Email user</label>
     <input type="email" name="email" class="form-control" placeholder="Type your email" required value="{{ user.email }}">
    </div>
    <div class="form-group">
     <label>Address user</label>
     <textarea name="address" class="form-control" placeholder="Type your address" required>{{ user.address }}</textarea>
    </div>
    <input type="submit" value="Save"> <button type="button" onclick="window.location.href='../../user'">Cancel</button>
   </form>
  </div>
 </div>
{% endblock %}

Terakhir, tambahkan link untuk kehalaman update dengan cara edit file index.volt pada path app/views/user/ menjadi seperti ini,
{% extends 'layouts/default1.volt' %}

{% block content %}
 <br/>
 Hello codedoct!!!
 <br><br>
 <div class="row">
  <div class="col-md-12">
   user list:
   <br><br>
   <table width="100%">
    <tr>
     <th>Name</th>
     <th>Action</th>
    </tr>
    {% for user in users %}
     <tr>
      <td>{{ user.name }}</td>
      <td><a href="user/{{ user.id }}">show</a> || <a href="user/edit/{{ user.id }}">edit</a></td>
     </tr>
    {% endfor %}
   </table>
   <br>
   <button onclick="window.location.href='user/create'">Create</button>
  </div>
 </div>
{% endblock %}

Sehingga tampilan halaman editnya akan tampak seperti ini,



===DONE!===

Phalcon - CRUD (Create)


Pada tutorial sebelumnya kita sudah membuat sistem read data user dari database dan menampilkannya dalam list maupun detail per masing-masing user. Pada tutorial kali ini kita akan membuat sistem create untuk menginputkan atau menambah data user pada database

Oke kita langsung saja memulai eksperiment create data pada phalcon,
Pertama, buat terlebih dahulu route untuk create dengan mengedit file router.php pada path app/config/ menjadi seperti ini,
<?php

$router = $di->getRouter();

// Define your routes here
/**
 * Get user lists data by query
 */
$router->addGet(
    "/user",
    [
        "controller"        => "user",
        "action"            => "index"
    ]
);
$router->addGet(
    "/user/{userId}",
    [
        "controller"        => "user",
        "action"            => "show"
    ]
);
$router->addGet(
    "/user/create",
    [
        "controller"        => "user",
        "action"            => "create"
    ]
);
$router->addPost(
    "/user/create",
    [
        "controller"        => "user",
        "action"            => "save"
    ]
);

$router->addGet(
    "/test",
    [
        "controller"        => "test",
        "action"            => "test"
    ]
);

$router->handle();

Selanjutnya, buat controller untuk menampilkan halaman create dan untuk menyimpan data user baru dengan mengedit file UserController.php pada path app/controllers/ menjadi seperti ini,
<?php

class UserController extends ControllerBase
{
    public function indexAction()
    {
     $users = Users::find();
     $this->view->title = "Phalcon - Users";
     $this->view->users = $users;
     // dd($users);
    }

    public function showAction($userId)
    {
     $conditions = ['userId'=>$userId];
     $user = Users::findFirst([
      'conditions' => 'id=:userId:',
      'bind' => $conditions,
  ]);
     $this->view->title = "Phalcon - User";
     $this->view->user = $user;
     // dd($users);
    }

    public function createAction()
    {
        $this->view->title = "Phalcon - Create user";
    }

    public function saveAction()
    {
        $name = $this->request->get('name');
        $email = $this->request->get('email');
        $address = $this->request->get('address');

        $user = new Users();
        $user->name = $name;
        $user->email = $email;
        $user->address = $address;

        if ($this->request->isPost()) {
            if ($user->create()) {
                return $this->response->redirect('user');
            }
        } else {
            $this->flash->error('User form is not valid.');
        }
    }
}

Kemudian, buat file view untuk create dengan membuat file baru dengan nama create.volt pada path app/views/user/ dan isikan code berikut,
{% extends 'layouts/default1.volt' %}

{% block content %}
 <br/>
 Hello codedoct!!!
 <br><br>
 <div class="row">
  <div class="col-md-12">
   <form method="POST">
    <div class="form-group">
     <label>Nama user</label>
     <input type="text" name="name" class="form-control" placeholder="Type your name" required>
    </div>
    <div class="form-group">
     <label>Email user</label>
     <input type="email" name="email" class="form-control" placeholder="Type your email" required>
    </div>
    <div class="form-group">
     <label>Address user</label>
     <textarea name="address" class="form-control" placeholder="Type your address" required></textarea>
    </div>
    <input type="submit" value="Save"> <button type="button" onclick="window.location.href='../user'">Cancel</button>
   </form>
  </div>
 </div>
{% endblock %}

Terakhir, edit file view index.volt pada path app/views/user/ menjadi seperti ini,
{% extends 'layouts/default1.volt' %}

{% block content %}
 <br/>
 Hello codedoct!!!
 <br><br>
 <div class="row">
  <div class="col-md-12">
   user list:
   <br><br>
   <table width="100%">
    <tr>
     <th>Name</th>
     <th>Action</th>
    </tr>
    {% for user in users %}
     <tr>
      <td>{{ user.name }}</td>
      <td><a href="user/{{ user.id }}">show</a></td>
     </tr>
    {% endfor %}
   </table>
   <br>
   <button onclick="window.location.href='user/create'">Create</button>
  </div>
 </div>
{% endblock %}

Sehingga hasilnya akan tampak seperti ini,



===DONE!===

Phalcon - CRUD (Read)



Back to phalcon, pada tutorial kemarin kita sudah sampai pada experiment menambahkan mirgation dan seeder secara manual pada project phalcon kita,

Pada tutorial kali ini, kita akan mulai bereksperiment membuat sistem crud, untuk tutorial crud yang pertama yaitu read, yang berarti mendapatkan data dari database yang kemudian menampilkannya pada project kita.

Oke langsung saja kita mulai experimentnya,
Pertama, edit file router.php pada path app/config/ yang satu mengarah pada list user dan yang satu lagi digunakan untuk melihat detail user,

<?php

$router = $di->getRouter();

// Define your routes here
/**
 * Get user lists data by query
 */
$router->addGet(
    "/user",
    [
        "controller"        => "user",
        "action"            => "index"
    ]
);
$router->addGet(
    "/user/{userId}",
    [
        "controller"        => "user",
        "action"            => "show"
    ]
);

$router->addGet(
    "/test",
    [
        "controller"        => "test",
        "action"            => "test"
    ]
);

$router->handle();

Selajutnya, edit file  UserController.php pada path app/controllers/ menjadi seperti ini
<?php

class UserController extends ControllerBase
{
    public function indexAction()
    {
     $users = Users::find();
     $this->view->title = "Phalcon - Users";
     $this->view->users = $users;
     // dd($users);
    }

    public function showAction($userId)
    {
     $conditions = ['userId'=>$userId];
     $user = Users::findFirst([
      'conditions' => 'id=:userId:',
      'bind' => $conditions,
  ]);
     $this->view->title = "Phalcon - User";
     $this->view->user = $user;
     // dd($users);
    }
}

Kemudian, buat file view index.volt pada path app/views/user/ yang digunakan untuk menampilkan list user kemudian isikan code berikut,
{% extends 'layouts/default1.volt' %}

{% block content %}
 <br/>
 Hello codedoct!!!
 <br><br>
 <div class="row">
  <div class="col-md-12">
   user list:
   <br><br>
   <table width="100%">
    <tr>
     <th>Name</th>
     <th>Action</th>
    </tr>
    {% for user in users %}
     <tr>
      <td>{{ user.name }}</td>
      <td><a href="user/{{ user.id }}">show</a></td>
     </tr>
    {% endfor %}
   </table>
   
  </div>
 </div>
{% endblock %}

Terakhir, buat file view show.volt pada path app/views/user yang digunakan untuk menampilkan detail user kemudian isikan code berikut,
{% extends 'layouts/default1.volt' %}

{% block content %}
 <br/>
 User Detail
 <br><br>
 <table width="100%">
  <tr>
   <td>Name</td><td>:</td><td>{{ user.name }}</td>
  </tr>
  <tr>
   <td>Email</td><td>:</td><td>{{ user.email }}</td>
  </tr>
  <tr>
   <td>Address</td><td>:</td><td>{{ user.address }}</td>
  </tr>
 </table>
 <br><br>
 <button onclick="window.location.href='../user'">Back</button>
{% endblock %}

Sehingga tampilannya akan tampak seperti ini,



===DONE!===