Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // controller
- public function action_index()
- {
- $this->template->title = ' / Struktura - lista użytkowników';
- $this->addCrumb('admin/user', 'Struktura');
- $this->addCrumb('admin/user/index', 'Lista użytkowników');
- $sort = Arr::get($_GET, 'sort', array('id' => 'desc'));
- $items = ORM::factory('admin_user');
- //foreach ( ORM::factory('user')->find_all() as $user ) echo Kohana::debug($user->roles);
- $items = $items->find_all();
- //$items->roles->find_all();
- print_r($items);
- $this->template->content = View::factory('tables/users')
- ->set('items', $items)
- ->set('sort', $sort)
- ->set('active', key(array_slice($sort, 0, 1)));
- }
- // model
- <?php defined('SYSPATH') OR die('No Direct Script Access');
- class Model_Admin_User extends Model_User
- {
- protected $_filters = array(TRUE => array('trim' => NULL));
- protected $_sorting = array('username' => 'DESC', 'id' => 'DESC');
- public $sortable = array('id', 'username', 'active');
- protected $_table_name = 'users';
- }
- // template
- <table>
- <tbody>
- <?php
- foreach($items as $item)
- {
- ?>
- <tr>
- <td><?php echo $item->id; ?></td>
- <td><?php echo $item->username; ?></td>
- <td><?php echo $item->roles->order_by('id', 'desc')->find()->name; ?></td>
- <td><?php echo $item->email; ?></td>
- <td><?php echo $item->active; ?></td>
- <td><input class="checkbox" type="checkbox" name="item[]" value="<?php echo $item->id; ?>" /></td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
Add Comment
Please, Sign In to add comment