Do you have that column activesales_count in your table company
Jul 14, 2018
9
Level 2
Query fails on production but runs on local environment
Hello.
The next query in successfully running on development environment, but fails on production one:
\App\Company::withCount('activesales')->where('activesales_count', '>', 0)->get();
(Returning "Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'activesales_count' in 'where clause'" error).
Company.php:
public function activesales()
{
return $this->hasMany('App\Post')->activeSale();
}
Post.php:
public function scopeActiveSale($query)
{
return $query->where('type', 'discount')->where('started_at', '<', Carbon::now())->where('finished_at', '>', Carbon::now());
}
Does anybody know what's the reason?
Thanks, in advance.
Please or to participate in this conversation.