0

I am using Laravel lucid framework and I have to call model setAttribute explicitly but getting below error:

ErrorException: Array to string conversion in

Code is

$user = new User;
$user->setAttribute('email',$this->email);
print_r($user);exit();

Please help

Thanks

3
  • What does dd($this->email) output? Commented Jun 23, 2021 at 15:49
  • it is simple email address, a string like ([email protected]) Commented Jun 23, 2021 at 15:52
  • Which of these lines throws that error? What have you tried to resolve the problem? Commented Jun 24, 2021 at 10:20

1 Answer 1

1

Try to use implode() method ? :

$test = implode('', $array);

$user = new User;
$user->setAttribute('email', $test);
print_r($user);
exit();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.