youl

1444 经验值

各位大侠:

   我在部署laravel中ping++服务端时,不知道这一步具体是怎样操作的。请明示,谢谢!

使用 Composer 的 autoload 引入

require_once('vendor/autoload.php');

这样可以得到想要的结果。谢谢!

在数据查询得到:
$user_ids = DB::select('select user_id as id from user_role where role_id = ?', [$id]);
$user_ids的值:
[{'id':1},{'id':2}]
我想要的结果是这样:
$user_ids=[1,2]
请各位大侠赐教。谢谢!

Vue代码如下:

<template>

<div class="panel-body">
    <div class="container">
        <div>
                <div class="form-group">
                    <label for="name">选择角色:</label>
                    <select>
                        <option v-for="r in roles">
                            <a v-on:click="clickRole(r.id)"> r.role </a>
                        </option>
                    </select>
                </div>

        </div>
    </div>
    <a v-for="role in roles" v-on:click="clickRole(role.id)"> role.role </a>
</div>

</template>

<script>

var data = {
    roles: [],
}
export default {
    data() {
        return data;
    },
    methods: {
        clickRole(id) {
            console.log(id)
        }
    },
    mounted() {
        axios.get('/roles/all').then(function (response) {
            data.roles = response.data
        })
    }
}

</script>

在下拉列表中的clickRole()方法不生效,在其他的a标签中生效。请问如何在列表中的clickRole()方法生效。谢谢!

已经解决。在手机号码和密码都正确是刷新当前页面。
app.js中的改动如下:

methods: {
        loginPost() {
            var self = this;
            axios.post('login', self.user).then(function (response) {
                window.location.reload()
            }).catch(function (error) {
                //表单提交失败,错误数组通过返回到表单 form submission failed, pass form  errors to errors array
                self.errors = error.response.data;
            });
        },
    }

LoginController改动如下:


$user = User::where('phone', $phone)->first();
Auth::login($user);
return 'OK';

我将view修改后,LoginController没有变,即可正常登录

<form class="form-horizontal" method="POST" action="{ route('login') }">
                            { csrf_field() }

                            <div class="form-group{ $errors->has('phone') ? ' has-error' : '' }">
                                <label for="phone" class="col-md-4 control-label">手机号码:</label>

                                <div class="col-md-6">
                                    <input id="phone" type="text" class="form-control" name="phone"
                                           value="{ old('phone') }" required autofocus>

                                    @if ($errors->has('phone'))
                                        <span class="help-block">
    <strong>{ $errors->first('phone') }</strong>
    </span>
                                    @endif

                                    <input id="msgPhone" type="hidden" class="form-control" name="msgPhone">

                                    @if ($errors->has('msgPhone'))
                                        <span class="help-block">
    <strong>{ $errors->first('msgPhone') }</strong>
    </span>
                                    @endif

                                </div>
                            </div>
                            <div class="form-group{ $errors->has('password') ? ' has-error' : '' }">
                                <label for="password" class="col-md-4 control-label">密码:</label>
                                <div class="col-md-6">
                                    <input id="password" type="password" class="form-control"
                                           name="password" {session('pwd')?'required':''}>
                                    @if ($errors->has('password'))
                                        <span class="help-block">
    <strong>{ $errors->first('password') }</strong>{session('pwd')}
    </span>
                                    @endif
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-6 col-md-offset-4">
                                    <button type="submit" class="btn btn-primary btn-block">
                                        @if(session('pwd'))
                                            登录
                                        @else
                                            获取密码
                                        @endif
                                    </button>
                                </div>
                            </div>
                        </form>