123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace App\Repositories\Models\Exam;
- use App\Repositories\Enums\ModelStatusEnum;
- use App\Repositories\Models\Model;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- /**
- * Class Paper.
- *
- * @package namespace App\Repositories\Models\Exam;
- */
- class Paper extends Model implements Transformable
- {
- use TransformableTrait;
- protected $table = 'exam_papers';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $guarded = [];
- public function topics()
- {
- return $this->belongsToMany(Topic::class, 'exam_paper_topic')->orderBy('sort', 'asc');
- }
- public function getAllotNumsAttribute()
- {
- return PaperResult::query()->where('paper_id', $this->attributes['id'])->where('status', ModelStatusEnum::OK)->where('is_answer', 0)->count();
- }
- }
|