1: <?php namespace Laravel\Auth\Drivers;
2:
3: use Laravel\Hash;
4: use Laravel\Config;
5: use Laravel\Database as DB;
6:
7: class Fluent extends Driver {
8:
9: 10: 11: 12: 13: 14: 15: 16:
17: public function retrieve($id)
18: {
19: if (filter_var($id, FILTER_VALIDATE_INT) !== false)
20: {
21: return DB::table(Config::get('auth.table'))->find($id);
22: }
23: }
24:
25: 26: 27: 28: 29: 30:
31: public function attempt($arguments = array())
32: {
33: $user = $this->get_user($arguments);
34:
35:
36:
37: $password = $arguments['password'];
38:
39: $password_field = Config::get('auth.password', 'password');
40:
41: if ( ! is_null($user) and Hash::check($password, $user->{$password_field}))
42: {
43: return $this->login($user->id, array_get($arguments, 'remember'));
44: }
45:
46: return false;
47: }
48:
49: 50: 51: 52: 53: 54:
55: protected function get_user($arguments)
56: {
57: $table = Config::get('auth.table');
58:
59: return DB::table($table)->where(function($query) use($arguments)
60: {
61: $username = Config::get('auth.username');
62:
63: $query->where($username, '=', $arguments['username']);
64:
65: foreach(array_except($arguments, array('username', 'password', 'remember')) as $column => $val)
66: {
67: $query->where($column, '=', $val);
68: }
69: })->first();
70: }
71:
72: }
73: