无法通过控制器将参数传递给页面

I am having trouble with a line in a controller:

public function checked(Request $request)
{
    $user = DB::table('user2s')->where('name', $request->name)->first();
    if (isset($user))
    return redirect ('/’,['user'=>$request->name]);
    else
    return redirect('/');
}

The error is "syntax error, unexpected 'user' (T_STRING)" line 29. The code before works because it recognizes when the passed name does not belong to a user in the users' table.

It works if written like: return $user->id; // or $user->body, the correct info is displayed.

It doesn't work with redirect (compact('user')) either.

Thank you.

public function checked(Request $request)
{
    $user = DB::table('user2s')->where('name', $request->name)->first();
    if (isset($user))
    return redirect ('/',['user'=>$request->name]);
    else
    return redirect('/');
}

Your error was caused in the first redirect. You have used instead of '.