Below I got my middleware that updates IP of the user.
namespace App\Http\Middleware;
use Closure;
use App\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Contracts\Auth\Guard;
class UserMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
public function handle($request, Closure $next)
{
User::where('id', $this->auth->user()->id)->update(['last_visit_ip' => '231']);
return $next($request);
}
}
Some notification is popping me up "Trying to get property of non-object"
Any idea how to fix it?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2C6sMee
via IFTTT
Aucun commentaire:
Enregistrer un commentaire