tophgg

1143 经验值

是这2个vue文件里的代码错误吗?我只要用this.$http.post和get这2个方法都会报这个错误.. 要怎么调试呢

mounted中能输出alert()然后弹窗之后就报这2个错误
···
TypeError: Cannot read property 'set' of undefined(…) error @ (program):292
TypeError: Cannot read property 'set' of undefined(…) bootstrap.js?5e63:31Uncaught (in promise)
···
之前做关注问题的时候都ok的,但是加了关注他之后,2个按钮都会报这个错误,而且就算注释了“关注他”的相关代码,之前那个“关注问题”也用不了 一直出这个错 找不到原因。。用了this.$http.get('/api/user/followers')之后network中也没有出现followers的请求,

试了一下,原来rules返回的数组里最后多了个逗号就会这样 去掉之后ok了 谢啦

大佬,问一下 跟着视频步骤做点击“提交” 在show方法里输出dd($request->get('topics'));
可是我自从加了话题之后,点击“提交”之后只会在原页面刷新了一次,跳转不到show方法里面去
然后我试了下把

 public function store(StoreQuestionRequest $request) // 依赖注入

里的StoreQuestionRequest改回Request之后 又可以跳转了,没加话题之前是可以正常提交的 这是什么原因呢? 是我漏改了吗

项目中有2个数据库,现在想关联report库中的tb_deposit_appstore表和gamesnapshot库中的tb_commodity_snapshot表

database.php里的collection配置如下

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', '192.168.0.202'),
            'database'  => env('DB_DATABASE', 'report'),
            'username'  => env('DB_USERNAME', 'xx'),
            'password'  => env('DB_PASSWORD', '123456'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

 'mysql_snapshot' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST_SNAPSHOT', '192.168.0.236'),
            'database'  => env('DB_DATABASE_SNAPSHOT', 'gamesnapshot'),
            'username'  => env('DB_USERNAME_SNAPSHOT', 'xx'),
            'password'  => env('DB_PASSWORD_SNAPSHOT', '123456'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
           // 'prefix'    => 'tb_',
            'strict'    => false,
        ],

查询构造器代码如下

$data = CommodityModel::select('tb_commodity_snapshot.*')
            ->join('report.tb_deposit_appstore','tb_deposit_appstore.id','=','tb_commodity_snapshot.commodity_id')
            ->get();

tb_commodity_snapshot表的model代码如下:

<?php

namespace App\Models\Report;

use Illuminate\Database\Eloquent\Model;

class Commodity extends Model
{
    /**
     * 限制读取字段
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * config/database配置中指定连接库名
     *
     * @var string
     */
    protected $connection = 'mysql_snapshot';

    /**
     * 设置模型表名
     *
     * @var string
     */
    protected $table = "tb_commodity_snapshot";

    public function depositAppstore()
    {
        return $this->belongsTo('App\Models\Game\DepositAppstore','commodity_id');
    }

    public function depositCommodity()
    {
        return $this->belongsTo('App\Models\Game\DepositCommodity','commodity_id');
    }
}

tb_deposit_appstore表的model配置如下

<?php

namespace App\Models\Game;

use Illuminate\Database\Eloquent\Model;

class DepositAppstore extends Model
{
    /**
     * 限制读取字段
     *
     * @var array
     */
    protected $guarded = [];

    protected $connection = 'mysql';
    /**
     * 设置模型表名
     *
     * @var string
     */
    protected $table = "tb_deposit_appstore";

}

错误信息:

QueryException in Connection.php line 729:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'report.tb_deposit_appstore' doesn't exist (SQL: select `tb_commodity_snapshot`.* from `tb_commodity_snapshot` inner join `report`.`tb_deposit_appstore` on `tb_deposit_appstore`.`id` = `tb_commodity_snapshot`.`commodity_id`)

目前尝试过在depositAppstore的model里面设置表名为

protected $table = "report.tb_deposit_appstore";

但是没什么卵用。。估计是因为join的时候直接写死表名了,上述错误应该是主查询仍在gamesnapshot库中查询,求问大神如何关联到report库中的表?

大神,我想问下我现在想关联2个不同库的表,host和port都不同,我分别配置了collection,可是用join('database.table_name','xx.id','=','yy.id');的时候识别不到database库。。难道是配置了prefix的问题?