/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $page = Input::get('page', 1);
     $limit = Input::get('limit', 10);
     $sortBy = Input::get('sortBy', 'sort_order');
     $sortDirection = Input::get('sortDirection', 'asc');
     $all = Input::get('all', false);
     if (!$all) {
         $data = $this->model->getByPage($page, $limit, $sortBy, $sortDirection, []);
     } else {
         // Grab all the contacts
         $data = $this->model->getAll($sortBy, $sortDirection);
     }
     return Response::json($data);
 }
                        <input type="password" name="password"  class="form-control">
                    </div>
                </div>
                <div class="panel-footer">
                    <input type="submit" class="btn btn-success" name="login_btn" value="login">
                    <a href="' . SITE_DIR . '" class="btn btn-default">Cancel</a>
                </div>
            </div>
        </div>
        </form>
    </div>
    ';
}
if ($_SESSION['login'] == 'admin') {
    $model = new model('unsubscribers');
    $unsubscribers = $model->getAll('udate DESC');
    if (isset($_POST['export'])) {
        $string = 'id;email;date' . "\n";
        foreach ($unsubscribers as $row) {
            $string .= $row['id'] . ';' . $row['email'] . ';' . date('Y-m-d H:i', strtotime($row['udate'])) . "\n";
        }
        header('Content-type:application/csv');
        header('Content-Disposition:attachment;filename=detox_subscribers_' . date('y-m-d') . '.csv');
        echo $string;
        exit;
    }
    echo date('Y-m-d H:i:s');
    echo '
<br><br><br>
    <div class="row">
        <div class="col-md-10 col-md-offset-1 col-sm-12">
Exemple #3
0
// we recommend you see the example model before see this controller
_::define_controller('example_4', function () {
    // if you need redirect te code to other controller
    // isn't necessary redirect the client, you can redirect the code using
    // _::redirect('new controller');
    // this line call new controller, and stop execution of current.
    _::redirect('example_3');
    // from here it doesn't execute.
    // if you like redirect client web browser, use:
    _::redirect('http://google.com', false);
    // this stop execution of current code.
    // if you need make all records of a table, you can use:
    $records = model::getAll();
    // this is SELECT * FROM TABLE;
    // if you like add limit, you can use second parammeter:
    $records = model::getAll('LIMIT 1');
    // in the second parammeter you can use WHERE clausule, ORDER BY and LIMIT.
    // getAll is a magic function of ORM, you don't need define it in the model.
    // now, $records get an Array of ids, you need make one object at each.
    // you can use foreach:
    /**
     $objects = array();
     foreach($records as $one_record)
     {
       $objects[] = new model($one_record['primary_key']);
     }
    */
    // OR YOU CAN USE FRAMEWORK TO MAKE EASY:
    $objects = _::factory($records, 'primary_key', 'model');
    // of course, you replace primary_key and model.
    // now you have one object each record.