类型转换不适用于Blade Directives

Consider the following piece of code:-

Blade::directive('avatar', function ($id) {
  $int = (int)$id;
  $u = User::find($int);
  return $u['avatar'];
});

I am calling this from a blade file like this:-

@avatar(2)

This works fine. However for some reason when a string is passed, the directive does not typecast the id into a number.

@avatar('2')

The code above is not working.

I tried it with different variations of the string to int conversion, but nothing seems to be working. Any suggestion would be most helpful. Thank you.