return View::factory('dashboard/users', $data);
<?php class Model_Sites extends Orm\Model { protected static $_many_many = array( 'users' => array( 'key_from' => 'id', 'key_through_from' => 'site_id', // column 1 from the table in between, should match a posts.id 'table_through' => 'sites_users', // both models plural without prefix in alphabetical order 'key_through_to' => 'user_id', // column 2 from the table in between, should match a users.id 'model_to' => 'Model_Users', 'key_to' => 'id', 'cascade_save' => true, 'cascade_delete' => false, ) ); } /* End of file sites.php */
<?php class Controller_Dashboard extends Controller_Template { private $user = NULL; public function action_index() { $data['sites'] = $this->list_sites(); $site = current($this->user->sites); Session::set("sites",$site); if ($site instanceof Model_Sites) { $data['users'] = $this->list_users($site->id); } $this->template->title = 'Dashboard » Index'; $this->template->content = View::factory('dashboard/index', $data); } public function before() { Session::instance(); $auth = Auth::instance(); if (!$auth->perform_check()) { Session::set_flash('notice', 'Please log in to see this page'); Response::redirect('welcome'); } $this->user = Model_Users::find() ->related('sites') ->where('username', '=', \Session::get('username')) ->get_one(); parent::before(); } public function list_sites() { if (empty($this->user->sites)) { return ""; } $data['sites'] = $this->user->sites; return View::factory('sites/index', $data); } public function list_users($site_id) { $site = Model_Sites::find() ->related('users') ->where('id', '=', $site_id) ->get_one(); $data['users'] = $site->users; if (empty($site->users)) { $data['users'] = ""; } return View::factory('dashboard/users', $data); } } /* End of file dashboard.php */
<div id="users"> <table> <tr> <th>Username</th> <th>Email</th> <th></th> <th></th> <th></th> </tr> <?php foreach ($users as $simpleusers): ?> <tr> <td><?php echo $simpleusers->username; ?></td> <td><?php echo $simpleusers->email; ?></td> <td><?php echo Html::anchor('users/view/'.$simpleusers->id, 'View'); ?></td> <td><?php echo Html::anchor('users/edit/'.$simpleusers->id, 'Edit'); ?></td> <td><?php echo Html::anchor('users/delete/'.$simpleusers->id, 'Delete', array('onclick' => "return confirm('Are you sure?')")); ?></td> </tr> <?php endforeach; ?></table> </div>
Error! ErrorException [ Error ]: Maximum execution time of 30 seconds exceeded PKGPATH/orm/classes/model.php @ line 689 684 throw new FrozenObject('No changes allowed.'); 685 } 686 687 if (in_array($property, static::primary_key()) and $this->{$property} !== null) 688 { 689 throw new \Fuel_Exception('Primary key cannot be changed.'); 690 } 691 if (array_key_exists($property, static::properties())) 692 { 693 $this->_data[$property] = $value; 694 } Backtrace COREPATH/base.php @ line 182 177 178if ( ! function_exists('fuel_shutdown_handler')) 179{ 180 function fuel_shutdown_handler() 181 { 182 return \Error::shutdown_handler(); 183 } 184} 185 186if ( ! function_exists('fuel_exception_handler')) 187{
<?php class Model_Sites extends Orm\Model { protected static $_many_many = array( 'users' => array( 'key_from' => 'id', 'key_through_from' => 'site_id', // column 1 from the table in between, should match a posts.id 'table_through' => 'sites_users', // both models plural without prefix in alphabetical order 'key_through_to' => 'user_id', // column 2 from the table in between, should match a users.id 'model_to' => 'Model_Users', 'key_to' => 'id', 'cascade_save' => true, 'cascade_delete' => false, ) ); protected static $_properties = array( 'id', 'name', 'url', 'unique_id' ); } /* End of file sites.php */
<?php class Model_Users extends Orm\Model { protected static $_many_many = array( 'sites' => array( 'key_from' => 'id', 'key_through_from' => 'user_id', // column 1 from the table in between, should match a posts.id 'table_through' => 'sites_users', // both models plural without prefix in alphabetical order 'key_through_to' => 'site_id', // column 2 from the table in between, should match a users.id 'model_to' => 'Model_Sites', 'key_to' => 'id', 'cascade_save' => true, 'cascade_delete' => false, ) ); protected static $_properties = array( 'id', 'username', 'password', 'group', 'email', 'last_login', 'login_hash', 'profile_fields' ); } /* End of file simpleusers.php */
It looks like you're new here. If you want to get involved, click one of these buttons!