<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Challenge extends Model
{
    use HasFactory;

    protected $table = 'challenges';  

    protected $primaryKey = 'id_challenge';

    protected $fillable = [
        'id_admin',
        'judul_challenge',
        'deskripsi',
        'exp',
        'id_badge',
        'tenggat_waktu',
    ];

    public function kelas()
{
    return $this->belongsToMany(
        Kelas::class,
        'challenge_kelas',
        'id_challenge',
        'id_kelas'
    );
}

public function soal()
{
    return $this->hasMany(SoalChallenge::class, 'id_challenge');
}

}