Laravel: adding a class to global.php -


I would like to register some event listeners in my Larewell project. To do this, I started my start \ global. Php added the following to the bottom of the file:

  Use UserLog; $ UserLog = New UserLog; Event :: Listen ('sentinel.user.login', function () {$ logData = array ('eventDescription' = & gt; "user login."); $ UserLog- & gt; submitLog ($ logData);}) ;   

When I execute that event, I get an error message Uses a statement with the non-compound name 'userlog' which has no effect < / Code>

Use user should drag into class model \ UserLog.php . It works in my other files, but not in the global .php I thought it was because the classes were not automatically loaded, but the code runs after code ClassLoader

Is not it possible to add a class to global.php ? Is there a better place that I should register events?

Try to use it (): Use

  \ UserLog;   

Note that namespace names (namespace separators with fully named namespace names such as fu \ times, which are not contrary to global names, such as Fubar), major backslash Unnecessary and not allowed because import names are fully qualified, and are not processed relative to existing namespaces.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -