parent
a00793bcdb
commit
0b6df835fc
11 changed files with 308 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Category extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_categories'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'content', |
||||||
|
'content_vi', |
||||||
|
'description', |
||||||
|
'status', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercises() |
||||||
|
{ |
||||||
|
return $this->hasMany(Exercise::class, 'category_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Exercise extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_exercises'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'subject_id', |
||||||
|
'lesson_name', |
||||||
|
'description', |
||||||
|
'level', |
||||||
|
'avatar', |
||||||
|
'status', |
||||||
|
'category_id', |
||||||
|
'skill_id', |
||||||
|
'year', |
||||||
|
'media_object_id', |
||||||
|
]; |
||||||
|
|
||||||
|
public function subject() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Subject::class, 'subject_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function category() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Category::class, 'category_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function skill() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Skill::class, 'skill_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function questionGroups() |
||||||
|
{ |
||||||
|
return $this->hasMany(QuestionGroup::class, 'exercise_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function questions() |
||||||
|
{ |
||||||
|
return $this->hasMany(Question::class, 'exercise_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class ExerciseQuestion extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_exercise_questions'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'exercise_id', |
||||||
|
'question_id', |
||||||
|
'position', |
||||||
|
]; |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Media extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_media'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'object_id', |
||||||
|
'file_name', |
||||||
|
'file_url', |
||||||
|
'mime_type', |
||||||
|
'size_bytes', |
||||||
|
'position', |
||||||
|
]; |
||||||
|
|
||||||
|
// Gợi ý: nếu cần polymorphic, bạn sẽ thay bằng morphTo() |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Question extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_questions'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'exercise_id', |
||||||
|
'content', |
||||||
|
'description', |
||||||
|
'group_id', |
||||||
|
'question_type_id', |
||||||
|
'level', |
||||||
|
'score', |
||||||
|
'answer', |
||||||
|
'explanation', |
||||||
|
'hint', |
||||||
|
'media_object_id', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercise() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Exercise::class, 'exercise_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function group() |
||||||
|
{ |
||||||
|
return $this->belongsTo(QuestionGroup::class, 'group_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function type() |
||||||
|
{ |
||||||
|
return $this->belongsTo(QuestionType::class, 'question_type_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function choices() |
||||||
|
{ |
||||||
|
return $this->hasMany(QuestionChoice::class, 'question_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function blanks() |
||||||
|
{ |
||||||
|
return $this->hasMany(QuestionBlank::class, 'question_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionBlank extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_blanks'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'question_id', |
||||||
|
'position', |
||||||
|
'correct_answer', |
||||||
|
'other_answers', |
||||||
|
]; |
||||||
|
|
||||||
|
public function question() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Question::class, 'question_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionChoice extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_choices'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'question_id', |
||||||
|
'label', |
||||||
|
'content', |
||||||
|
'is_correct', |
||||||
|
'media', |
||||||
|
'media_object_id', |
||||||
|
'position', |
||||||
|
]; |
||||||
|
|
||||||
|
public function question() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Question::class, 'question_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionGroup extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_groups'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'content', |
||||||
|
'content_vi', |
||||||
|
'exercise_id', |
||||||
|
'is_question_order_fixed', |
||||||
|
'is_option_order_fixed', |
||||||
|
'position', |
||||||
|
'paragraph', |
||||||
|
'media_object_id', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercise() |
||||||
|
{ |
||||||
|
return $this->belongsTo(Exercise::class, 'exercise_id'); |
||||||
|
} |
||||||
|
|
||||||
|
public function questions() |
||||||
|
{ |
||||||
|
return $this->hasMany(Question::class, 'group_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class QuestionType extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_question_types'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'name', |
||||||
|
'code', |
||||||
|
'description', |
||||||
|
'status', |
||||||
|
]; |
||||||
|
|
||||||
|
public function questions() |
||||||
|
{ |
||||||
|
return $this->hasMany(Question::class, 'question_type_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||||
|
|
||||||
|
class Skill extends Model |
||||||
|
{ |
||||||
|
use SoftDeletes; |
||||||
|
|
||||||
|
protected $table = 'se_skills'; |
||||||
|
|
||||||
|
protected $fillable = [ |
||||||
|
'name', |
||||||
|
'code', |
||||||
|
'description', |
||||||
|
]; |
||||||
|
|
||||||
|
public function exercises() |
||||||
|
{ |
||||||
|
return $this->hasMany(Exercise::class, 'skill_id'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class Subject extends Model |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
Loading…
Reference in new issue