Skip to content

Instantly share code, notes, and snippets.

@hmic
Last active October 19, 2015 14:42
Show Gist options
  • Save hmic/f5ef1cb41b6e99932941 to your computer and use it in GitHub Desktop.
Save hmic/f5ef1cb41b6e99932941 to your computer and use it in GitHub Desktop.
soft fail paginate (Cakephp 3)
<?php
use App\Controller;
class CompaniesController extends AppController {
public function index() {
try {
$this->set('companies', $this->paginate($this->Companies->find()));
} catch(\Cake\Network\Exception\NotFoundException $e) {
return $this->redirect(['page' => 1] + $this->request->query);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment