错误:无法将类stdClass的对象转换为字符串 [英] ERROR: Object of class stdClass could not be converted to string
本文介绍了错误:无法将类stdClass的对象转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行下面的代码时
$id = Input::get('branch_id');
$retailer_code = DB::table('branches')->select('retailer_code')->where('id', $id)->first();
$user = new User;
$user->user_firstname = Input::get('user_firstname');
$user->user_lastname = Input::get('user_lastname');
$user->user_email = Input::get('user_email');
$user->username = Input::get('username');
$user->password = Hash::make(Input::get('password'));
$user->position_id = Input::get('position_id');
$user->retailer_code = $retailer_code;
$user->branch = Input::get('branch_code');
$user->status = "1";
$user->save();
return Redirect::to('admin/users')->with('message', 'New User Added!');
我收到此错误类stdClass的对象无法转换为字符串"
I get this error "Object of class stdClass could not be converted to string"
推荐答案
问题可能在此行上:
$user->retailer_code = $retailer_code;
$retailer_code
是一个对象,您需要像这样获取它的属性:
$retailer_code
is an object and you need to get the property of it like this:
$user->retailer_code = $retailer_code->retailer_code;
这篇关于错误:无法将类stdClass的对象转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文