Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未找到列:laravel雄辩关系中的1054未知列_Php_Laravel_Eloquent_Laravel 5.4 - Fatal编程技术网

Php 未找到列:laravel雄辩关系中的1054未知列

Php 未找到列:laravel雄辩关系中的1054未知列,php,laravel,eloquent,laravel-5.4,Php,Laravel,Eloquent,Laravel 5.4,我试图在当前时间戳上计算homecourt上的日程安排数,现在我在homecourt、userhomecourt和schedule之间的laravel中尝试了hasManyThrough,但出现了此错误 SQLSTATE[42S22]: Column not found: 1054 Unknown column 'timeFrom' in 'where clause' (SQL: select count(*) as aggregate from `tblHomeCourts` where `h

我试图在当前时间戳上计算homecourt上的日程安排数,现在我在homecourt、userhomecourt和schedule之间的laravel中尝试了
hasManyThrough
,但出现了此错误

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'timeFrom' in 'where clause' (SQL: select count(*) as aggregate from `tblHomeCourts` where `homeCourtId` = 1 and `timeFrom` <= 1496207469 and `timeTo` > 1496207469)
我哪里错了?请改正一下

class HomeCourt extends Model
{
    protected $table = 'tblHomeCourts';
    protected $primaryKey = 'homeCourtId';
    protected $appends = ['homeCourtProfilePicUrl'];
    public static $snakeAttributes = false;
    protected $fillable = [
        'homeCourtName',
        'cityId',
        'homeCourtProfilePic',
        'gameType',
        'courtType',
        'numberOfCourts',
        'lights',
        'membershipStatus',
        'dayCost',
        'address',
        'lat',
        'long',
        'userId',
        'homeCourtStatus',
    ];
    protected $hidden = ['homeCourtProfilePic', 'created_at', 'updated_at', 'homeCourtStatus', 'userId', 'cityId'];

    public function getHomeCourtProfilePicUrlAttribute()
    {
        return ($this->attributes['homeCourtProfilePic'] != "" || $this->attributes['homeCourtProfilePic'] != null) ? Constant::HOMECOURT_PROFILE_URL . $this->attributes['homeCourtProfilePic'] : null;
    }

    /*relation for there now*/
    public function user()
    {
        return $this->belongsTo(User::class, 'homeCourtId', 'homeCourtId');
    }

    /*player count*/
    public function playerCount()
    {
        return $this->hasManyThrough(Schedule::class,UserHomeCourt::class,'homeCourtId','userHomeCourtId','homeCourtId');
    }


}

您的
tblHomeCourts
表中是否有
timeFrom
列?不,它在明细表中。请阅读此
SQLSTATE[42S22]:未找到列:where子句中的1054未知列“timeFrom”(SQL:select count(*)作为从
tblHomeCourts`where
homeCourtId
=1和
timeFrom
1496207469)的聚合)`它试图从
tblHomeCourts
hmm中获取
timeFrom
,我知道我的关系中有错误,你能纠正一下吗?请发布你的完整模型
class HomeCourt extends Model
{
    protected $table = 'tblHomeCourts';
    protected $primaryKey = 'homeCourtId';
    protected $appends = ['homeCourtProfilePicUrl'];
    public static $snakeAttributes = false;
    protected $fillable = [
        'homeCourtName',
        'cityId',
        'homeCourtProfilePic',
        'gameType',
        'courtType',
        'numberOfCourts',
        'lights',
        'membershipStatus',
        'dayCost',
        'address',
        'lat',
        'long',
        'userId',
        'homeCourtStatus',
    ];
    protected $hidden = ['homeCourtProfilePic', 'created_at', 'updated_at', 'homeCourtStatus', 'userId', 'cityId'];

    public function getHomeCourtProfilePicUrlAttribute()
    {
        return ($this->attributes['homeCourtProfilePic'] != "" || $this->attributes['homeCourtProfilePic'] != null) ? Constant::HOMECOURT_PROFILE_URL . $this->attributes['homeCourtProfilePic'] : null;
    }

    /*relation for there now*/
    public function user()
    {
        return $this->belongsTo(User::class, 'homeCourtId', 'homeCourtId');
    }

    /*player count*/
    public function playerCount()
    {
        return $this->hasManyThrough(Schedule::class,UserHomeCourt::class,'homeCourtId','userHomeCourtId','homeCourtId');
    }


}