Guest User

Untitled

a guest
Jul 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // controller
  2. public function action_index()
  3. {
  4. $this->template->title = ' / Struktura - lista użytkowników';
  5. $this->addCrumb('admin/user', 'Struktura');
  6. $this->addCrumb('admin/user/index', 'Lista użytkowników');
  7.  
  8. $sort = Arr::get($_GET, 'sort', array('id' => 'desc'));
  9.  
  10. $items = ORM::factory('admin_user');
  11.  
  12. //foreach ( ORM::factory('user')->find_all() as $user ) echo Kohana::debug($user->roles);
  13. $items = $items->find_all();
  14. //$items->roles->find_all();
  15.  
  16. print_r($items);
  17.  
  18. $this->template->content = View::factory('tables/users')
  19. ->set('items', $items)
  20. ->set('sort', $sort)
  21. ->set('active', key(array_slice($sort, 0, 1)));
  22. }
  23.  
  24. // model
  25. <?php defined('SYSPATH') OR die('No Direct Script Access');
  26.  
  27. class Model_Admin_User extends Model_User
  28. {
  29. protected $_filters = array(TRUE => array('trim' => NULL));
  30.  
  31. protected $_sorting = array('username' => 'DESC', 'id' => 'DESC');
  32.  
  33. public $sortable = array('id', 'username', 'active');
  34.  
  35. protected $_table_name = 'users';
  36.  
  37. }
  38.  
  39.  
  40. // template
  41.  
  42. <table>
  43.  
  44. <tbody>
  45. <?php
  46. foreach($items as $item)
  47. {
  48. ?>
  49. <tr>
  50. <td><?php echo $item->id; ?></td>
  51. <td><?php echo $item->username; ?></td>
  52. <td><?php echo $item->roles->order_by('id', 'desc')->find()->name; ?></td>
  53. <td><?php echo $item->email; ?></td>
  54. <td><?php echo $item->active; ?></td>
  55. <td><input class="checkbox" type="checkbox" name="item[]" value="<?php echo $item->id; ?>" /></td>
  56. </tr>
  57. <?php
  58. }
  59. ?>
  60. </tbody>
  61. </table>
Add Comment
Please, Sign In to add comment