GEOFFREY MWANGI GEOFFREY MWANGI - 3 years ago 150
PHP Question

Laravel passing data type in a construct

Am new to laravel and 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