Laravel/PHP: TypeError: App\Services\Mailer::send(): Argument #1 ($user) must be of type App\Models\User, null given
A function received a value of the wrong type — often null where an object was required.
TypeError: Argument #1 ($user) must be of type App\Models\User, null givenmust be of type string, null givenArgument 1 passed to must be an instance of, null givenTypeError: Illuminate\...::method(): Argument #2 must be of typeReturn value must be of type, null returned Meaning
PHP 7+/8 enforce typed parameters. The message tells you the expected and received types and the call site. Commonly a query returned null (Auth::user() for guests, find()), or string vs int from request input. Add checks, use nullable types (?User), or cast.
Common causes
- null passed from
find()/first()/Auth::user() - String input where int expected (strict types)
- Wrong object type (Collection vs Model)
- Missing return type conversion
- Optional dependency not bound
⚡ Quick fix
- Guard against null before calling
- Type-hint as nullable if appropriate (
?User) - Cast request input:
(int) $request->id
Detailed fix by platform
Laravel
$user = $request->user() ?? abort(401);
How to diagnose
- Expected — Type required?
- Given — What arrived?
- Source — Where null came from?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Laravel
- MassAssignmentException Laravel: Illuminate\Database\Eloquent\MassAssignmentException: Add [x] to fillable property to allow mass assignment
- The GET method is not supported for route Laravel: The GET method is not supported for route x. Supported methods: POST (MethodNotAllowedHttpException)
- Route [login] not defined Laravel: Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026