-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTest.php
57 lines (47 loc) · 1.18 KB
/
Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Test
*
* @package App
* @property string $course
* @property string $lesson
* @property string $title
* @property text $description
* @property tinyInteger $published
*/
class Test extends Model
{
use SoftDeletes;
protected $fillable = ['title', 'description', 'published', 'course_id', 'lesson_id'];
/**
* Set to null if empty
* @param $input
*/
public function setCourseIdAttribute($input)
{
$this->attributes['course_id'] = $input ? $input : null;
}
/**
* Set to null if empty
* @param $input
*/
public function setLessonIdAttribute($input)
{
$this->attributes['lesson_id'] = $input ? $input : null;
}
public function course()
{
return $this->belongsTo(Classes::class, 'id')->withTrashed();
}
public function lesson()
{
return $this->belongsTo(Lesson::class, 'lesson_id')->withTrashed();
}
public function questions()
{
return $this->belongsToMany(Question::class, 'question_test')->withTrashed();
}
}