Last active
April 1, 2016 23:45
-
-
Save icaroscherma/a3415b90f391a17168430dc575661360 to your computer and use it in GitHub Desktop.
CakePHP 3: Migrating from scope to finder (auth)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// src/Controller/AppController.php | |
$this->loadComponent('Auth', [ | |
'authenticate' => [ | |
'Form' => [ | |
'fields' => [ | |
'username' => 'email', | |
'password' => 'password' | |
], | |
// Older "scope" / "contain" | |
'finder' => 'auth' | |
] | |
] | |
] | |
); | |
// src/Model/Table/Users.php | |
public function findAuth(\Cake\ORM\Query $query, array $options) | |
{ | |
$query | |
// ->select(['id', 'email', 'password']) | |
->where(['Users.active' => 1]); | |
return $query; | |
} |
Author
icaroscherma
commented
Apr 1, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment