Why do I get an empty collection result using the scope? This is my current controller:
class PunxController extends Controller {
public function index()
{
$scholars = Scholar::age()->get();
return $scholars;
}
}
and on my model Scholar:
use Illuminate\Database\Eloquent\Model;
class Scholar extends Model {
protected $primaryKey = 'scholar_id';
protected $fillable = ['ngo_id','scholar_lname','scholar_fname','scholar_image','scholar_nickname','scholar_cityAddress','scholar_permaAddress','scholar_birthday','scholar_placebirth','scholar_age','scholar_gender','scholar_email','scholar_contact'];
public static function scopeAge($query)
{
return $query->where('scholar_age', '>=', 5);
}
}
and the result is:
but when I try on PHPMYADMIN:
Update1
result of DB::getQueryLog():



\DB::enableQueryLog()before you run the query and then usedd(\DB::getQueryLog())after to see what was actually run. Then post the result here please!