GEOFFREY MWANGI GEOFFREY MWANGI - 3 years ago 171
PHP Question

Passing data type in a construct

I'am trying to pass a data of type string to a construct to ensure that a string is always passed

In my reset password class I have

class RequestResetPassword extends Mailable
{

public function __construct(User $user, String $resettoken)
{

}


The user part is okay as it is of type user Model but how do i go about the access token part by stating that it must always be a string

The above generates an error

App string not found.

Answer Source

It should be string (lowercase), since is not a class. Something like:

public function __construct(User $user, string $resettoken)
{

}

Check the PHP documentation on type declarations.

By the way, this is not a Laravel question.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download