Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Eloquent Save Item Error?

Tags:

php

laravel

When I try saving an item's to my database I get

Method Clients::__toString() must return a string value 

Current code

        $name = Input::get('email');
        $client = Input::get('client');
        $website = Input::get('website');
        $userassign = Input::get('userassign');

        $client = new Clients();
        $client->name = $name;
        $client->client = $client;
        $client->website = $website;
        $client->parent = $userassign;


        $client->save();

Any ideas?

like image 719
Brent Avatar asked Dec 11 '22 04:12

Brent


1 Answers

You're redefining $client.

        $name = Input::get('email');
        $clientInput = Input::get('client');
        $website = Input::get('website');
        $userassign = Input::get('userassign');

        $client = new Clients(); 
        $client->name = $name; 
        $client->client = $clientInput; //Here was your problem
        $client->website = $website;
        $client->parent = $userassign;


        $client->save();
like image 144
rdiz Avatar answered Dec 23 '22 07:12

rdiz