Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Vote | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| casts | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| user | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| joke | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 6 | use Illuminate\Database\Eloquent\Model; |
| 7 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 8 | |
| 9 | class Vote extends Model |
| 10 | { |
| 11 | use HasFactory; |
| 12 | |
| 13 | protected $fillable = [ |
| 14 | 'user_id', |
| 15 | 'joke_id', |
| 16 | 'rating', |
| 17 | ]; |
| 18 | |
| 19 | protected function casts(): array |
| 20 | { |
| 21 | return [ |
| 22 | 'rating' => 'integer', |
| 23 | ]; |
| 24 | } |
| 25 | |
| 26 | public function user(): BelongsTo |
| 27 | { |
| 28 | return $this->belongsTo(User::class); |
| 29 | } |
| 30 | |
| 31 | public function joke(): BelongsTo |
| 32 | { |
| 33 | return $this->belongsTo(Joke::class); |
| 34 | } |
| 35 | } |