orchestral/html — pull request #22 by wisepotato (2014-07-25 20:27:32+00:00)
Title: 2.2

Having trouble editing the grid to ONLY allow model, and only afterwards add the pagination, so we can add search sort. etcetera.To give an example of how I did this in Orchestra 1.x:

```php
/**
* Attach Eloquent results as row and allow pagination (if required)
*
*
*	// add model without pagination
*	$table->with(User::all());
*
*	// add model with pagination
*	$table->with(User::paginate(30), true);
*
*
* @access public
* @param Eloquent $model
* @param bool $paginate
* @return void
*/
public function with($model)
{
$this->model = $model;

//search
if($this->searchable)
{
//get input
$search = \Input::get('q');
foreach($this->searchable_columns as $column)
{
$this->model = $this->model->or_where($column, 'like', '%' . $search . '%');
}
}
if($this->sortable)
{

$current_sort = \Input::get('sort');
$current_order = \Input::get('order');
if(in_array($current_sort, $this->sortable_columns) && in_array($current_order, array('asc', 'desc')))
{
\Log::write('info', $current_sort . ' and ' . $current_order);
$this->model = $this->model->order_by($current_sort, $current_order);
}

}

if($this->paginate)
{
$this->model = $this->model->paginate($this->per_page);
$last_query = \DB::last_query();

\Log::write('info', print_r($last_query, true));
$this->search_time = $last_query['time'];
$this->rows($this->model->results);

}
else
{

$this->rows($this->model->get());
}
}
```

This worked really well. Cant get this to work on Orchestra 2