墨生人

1087 经验值

大神,有没有打算出一个关于swoole框架或配置的系列项目,或者有比较好的例子推荐,拜谢

如果我想增删改成功以后,出现一个小弹窗,vue有没有相关的插件,或者本身自带这个功能?

管它呢,现在清楚坑在哪就够了,学习过程,真正上线使用时再拿出来讨论

我安装vue-axios的时候,报了这个依赖错误UNMET PEER DEPENDENCY eslint-plugin-promise@2.0.1。
如果我按照说明升级到
npm WARN eslint-config-standard@6.2.1 requires a peer of eslint-plugin-promise@>=3.3.0 but none was installed.
这个,会对整体vue-cli产生bug吗

现在好了,我删掉重新复制了一遍,就好了,不知道什么情况,可能是缓存

<?php
/**
 * Created by PhpStorm.
 * User: zhoujie
 * Date: 16/10/30
 * Time: 下午11:03
 */
namespace App\Http\Controllers\Test;

use App\Http\Controllers\BaseController;
use App\Models\Test;

class TestUpdateController extends BaseController
{
    public function __construct()
    {
        parent::__construct();
    }

    public function create()
    {
        $param = $this->validate_process();
        $id = Test::insertGetId($param);
        reset($param); $param['id'] = $id;
        return $id ? response()->json($param) : $this->errorOutput('CREATE_FAILD');
    }

    public function update()
    {
        $this->validation(['id' => 'required|numeric'], ['id' => '测试id']);
        $param = $this->validate_process();
        $id = intval($this->input['id']);
        $res = Test::where('id', $id)->update($param);
        return $res ? response()->json(['success' => 1]) : $this->errorOutput('UPDATE_FAILD');
    }

    public function delete()
    {
        $this->validation(['id' => 'required|numeric'], ['id' => '测试id']);
        $id = intval($this->input['id']);
        $res = Test::destroy($id);
        return $res ? response()->json(['success' => 1]) : $this->errorOutput('DELETE_FAILD');
    }

    private function validate_process()
    {
        $rules = [
            'name'     => 'required|unique:mysql-i.users|alpha_dash|max:32',
            'password' => 'required|alpha_dash|min:6|max:32',
            'tel'      => 'required|digits_between:3, 18',
            'email'    => 'required|email|min:3|max:32',
            'avatar'   => 'min:3'
        ];
        $attr = [
            'name'     => '用户名',
            'password' => '用户密码',
            'tel'      => '用户电话',
            'email'    => '用户邮箱',
            'avatar'   => '用户头像',
        ];
        if (!empty($this->input['id'])) { $rules['name'] = 'required|alpha_dash|max:32'; }
        $this->validation($rules, $attr);
        return [
            'name'     => trim($this->input['name']),
            'password' => trim($this->input['password']),
            'tel'      => trim($this->input['tel']),
            'email'    => trim($this->input['email']),
            'avatar'   => $this->input['avatar'] ? serialize($this->input['avatar']) : '',
            'create_time' => TIMENOW
        ];
    }
}