saybye720

114 经验值

@JellyBool 谢谢,老大指点,应该不是_token的事,input上来的值太多了,我懒得一一获取就直接用$data了,update到主表user是没有问题的,update到附加表profile就不行了。还是获取对应字段更新吧。

users【用户表】

users表中只存了用户名,手机号,密码

++++++++++++++++++++++++++++++++++

user_profile【用户信息表】

性别,头像,认证信息之类的字段都存到此表

后台编辑用户的时候,提交后

public function update(Request $request, $id)
    {
        $this->validate($request, [
            'name' => 'required|min:3|max:20',
            'phone' => 'required|digits:11|unique:users,phone,' . $id,
        ]);
        $user = User::find($id);
        $data = $request->all();
        if($request->password) {
            $data['password'] = Hash::make($request->password);
        } else {
            $data['password'] = $user->password;
        }
        if ($request->file) {
            $validate = ImageHelper::validate($request->file, 2000000);

            if (!$validate['success']) {
                return redirect()->back()->with('error', $validate['message']);
            }

            $image = ImageHelper::create($request->file, 600, 'admin/images/users/');

            $data['image'] = $image['filename'];
        }
        $user->update($data);
        $user->UserProfile()->update($data);

        return redirect()->route('admin::users.index')->with('success', 'User successfully updated');
    }

关联模型中是这样写的

    public function userProfile()
    {
        return $this->hasOne('App\UserProfile', 'user_id', 'id');
    }

更新的时候报错

QueryException in Connection.php line 655:
                            SQLSTATE[42S22]:
 Column not found: 1054 Unknown column '_token' in 'field list' (SQL: 
update `s_user_profile` set `_token` = 
2Apiil1kSDOeNzNendwjcuRj4lJTDjb11slu9nfn, `name` = XiaoYao, `phone` = 
18660407361, `sex` = 2, `password` = 
y$dWBZ/A/WGinWRlYvuFZfAeHYoq2sr46DzjDme83WETzAMR4wh9TrC, `description` =
 
测试内容</p>, `updated_at` = 2016-04-25 
08:14:38 where `s_user_profile`.`user_id` = 1 and 
`s_user_profile`.`user_id` is not null)

谢谢大神们。

@JellyBool 运行完 npm install node-sass 这个还是报错。真是醉了。 下面哪种重装的方法试了好多遍了,错误都一样。哎,

谢了

win10下,装的最新Homestead,gulp的时候报错。

vagrant@homestead:~/Code/fmk$ gulp
[07:14:50] Using gulpfile ~/Code/fmk/gulpfile.js
[07:14:50] Starting 'default'...
[07:14:50] Starting 'styles'...

Fetching Styles Source Files...
   - resources/assets/dep/bootstrap/dist/css/bootstrap-paper.min.css
   - resources/assets/dep/animate-css/animate-css.min.css
   - resources/assets/dep/textAngular/dist/textAngular.css
   - resources/assets/dep/font-awesome/css/font-awesome.min.css


Saving To...
   - public/admin/css/dep.css

[07:14:55] Finished 'default' after 5.05 s
[07:14:55] gulp-notify: [Laravel Elixir] Stylesheets Merged!
[07:14:55] Finished 'styles' after 5.47 s
[07:14:55] Starting 'sass'...
[07:14:56] 'sass' errored after 366 ms
[07:14:56] Error: The `libsass` binding was not found in /home/vagrant/Code/fmk/node_modules/node-sass/vendor/linux-x64-47/binding.node
This usually happens because your node version has changed.
Run `npm rebuild node-sass` to build the binding for your current node version.
    at Object.sass.getBinaryPath (/home/vagrant/Code/fmk/node_modules/node-sass/lib/extensions.js:158:11)
    at Object.<anonymous> (/home/vagrant/Code/fmk/node_modules/node-sass/lib/index.js:16:36)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/home/vagrant/Code/fmk/node_modules/gulp-sass/index.js:186:21)
    at Module._compile (module.js:425:26)
[07:14:56] Error in plugin 'run-sequence'
Message:
    An error occured in task 'sass'.
vagrant@homestead:~/Code/fmk$ gulp -v
[07:19:45] CLI version 3.9.0
[07:19:45] Local version 3.9.1

运行 npm install 的时候也报错。如下

npm install --no-bin-links
npm WARN deprecated [email protected]: Please use gulp-clean-css
npm WARN install Couldn't install optional dependency: Unsupported
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated [email protected]: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated [email protected]: this package has been reintegrated into npm and is now out of date with respect to npm
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--no-bin-links"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6

npm ERR! Maximum call stack size exceeded
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--no-bin-links"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! path npm-debug.log.514498fc5bd9b23815a265daa282db93
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename

npm ERR! ETXTBSY: text file is busy, rename 'npm-debug.log.514498fc5bd9b23815a265daa282db93' -> 'npm-debug.log'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/Code/fmk/npm-debug.log

求大神指点。