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?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire