我想让这一行开始工作fun readFile(path: String): Unit {
var input: InputStream = FileInputStream(path)
var string: String = ""
var tmp: Int = -1
var bytes: ByteArray = ByteArray(1024)
while((tmp=input.read(bytes))!=-1) { }
}
关注much discussion和failed attempts
我需要帮助填写一个雄辩的模型
还有一个守卫的问题
http://laravel.io/forum/01-06-2016-massassignmentexception-ignoring-fillable-guarded-is-set
我用$user->profile()->fill($input['profile'])->save();
个人资料模型
protected $guarded = ['id'];
用户模型
public function user(){
return $this->belongsTo('App\User');
}
控制器
public function profile(){
return $this->hasOne('App\Profile', 'user_id');
}
注意我是如何手动填充的,这显然不太理想。 this is the result i am trying to achieve
答案 0 :(得分:0)
根据我的理解,您希望在一行中填充配置文件属性,
你试过fill()
方法??
在else
部分尝试这种方式,或者在您想要它的时候,我希望这可以帮助您
$profile = new Profile;
$profile->fill($input['profile']);
$user->profile()->save($profile);