File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
27
27
- Added item checkout and scan-in.
28
28
- Analytics: The ` getRows() ` method is deprecated. Iterate over the ` Report ` instead.
29
29
- Made package auto-discoverable in Laravel 5.5+.
30
+ - Added helper method ` Users::findOne() ` to get the first match from a search.
30
31
31
32
### Changed
32
33
Original file line number Diff line number Diff line change 7
7
/**
8
8
* The Model class is our base class.
9
9
*/
10
- abstract class Model
10
+ abstract class Model implements \JsonSerializable
11
11
{
12
12
/* @var Client */
13
13
protected $ client ;
@@ -75,4 +75,9 @@ public function __get($key)
75
75
76
76
return null ;
77
77
}
78
+
79
+ public function jsonSerialize ()
80
+ {
81
+ return $ this ->data ;
82
+ }
78
83
}
Original file line number Diff line number Diff line change @@ -34,6 +34,18 @@ public function get($user_id, $params = [])
34
34
->setParams ($ params );
35
35
}
36
36
37
+ /**
38
+ * Get the first user matching a given query, or NULL if not found.
39
+ *
40
+ * @param string $query
41
+ * @param array $options
42
+ * @return User|null
43
+ */
44
+ public function findOne ($ query , array $ options = [])
45
+ {
46
+ return $ this ->search ($ query , $ options )->current ();
47
+ }
48
+
37
49
/**
38
50
* Iterates over all users matching the given query.
39
51
* Handles continuation.
You can’t perform that action at this time.
0 commit comments