File tree Expand file tree Collapse file tree 1 file changed +29
-2
lines changed
Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change 1212 *
1313 * @author Michael Darko
1414 * @since 1.0.0
15- * @version 2.0
15+ * @version 2.3. 0
1616 */
1717class Request
1818{
@@ -316,13 +316,40 @@ public static function validate(array $rules)
316316 return \Leaf \Form::validate (static ::body (false ), $ rules );
317317 }
318318
319+ /**
320+ * @return \Leaf\Auth
321+ */
322+ protected static function auth ()
323+ {
324+ if (!class_exists ('\Leaf\Auth ' )) {
325+ throw new \Exception ("You need to install the leaf-auth package to use the auth helper " );
326+ }
327+
328+ if (!(\Leaf \Config::get ('auth.instance ' ))) {
329+ \Leaf \Config::set ('auth.instance ' , new \Leaf \Auth ());
330+ }
331+
332+ return \Leaf \Config::get ('auth.instance ' );
333+ }
334+
335+ /**
336+ * Get the authenticated user
337+ */
338+ public static function user ()
339+ {
340+ return static ::auth ()->user ();
341+ }
342+
319343 /**
320344 * Handle errors from validation
321345 * @return array
322346 */
323347 public static function errors ()
324348 {
325- return \Leaf \Form::errors ();
349+ return array_merge (
350+ \Leaf \Form::errors (),
351+ static ::auth ()->errors ()
352+ );
326353 }
327354
328355 /**
You can’t perform that action at this time.
0 commit comments