"integer", "user_id" => "integer", "quiz_time" => "integer", "points" => "double", "result" => "double", "accuracy" => "double", ]; public function __construct(array $attributes = []) { parent::__construct($attributes); $this->table = acadlix()->helper()->acadlix_table_prefix('statistic_ref'); } public function setUserIdAttribute($value) { $this->attributes['user_id'] = $value == 0 ? NULL : $value; } public function setUserTokenAttribute($value) { $this->attributes['user_token'] = empty($value) ? NULL : $value; } public function quiz() { return $this->belongsTo(acadlix()->model()->quiz(), 'quiz_id', 'ID') ->ofQuiz(); } public function statistics() { return $this->hasMany(acadlix()->model()->statistic(), "statistic_ref_id", "id"); } public function user() { return $this->belongsTo(acadlix()->model()->wpUsers(), 'user_id', 'ID'); } public function getEvaluatedCount() { return $this->statistics()->where('is_evaluated', 1)->count(); } } }