| 1 | <?php |
||
| 10 | class LikeDislike extends Model |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Table name. |
||
| 14 | * |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $table = 'likes_dislikes'; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The attributes that are mass assignable. |
||
| 21 | * |
||
| 22 | * @var array |
||
| 23 | */ |
||
| 24 | protected $fillable = ['user_id', 'video_id', 'type']; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * The attributes that should be hidden for arrays. |
||
| 28 | * |
||
| 29 | * @var array |
||
| 30 | */ |
||
| 31 | protected $hidden = []; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * User relation. |
||
| 35 | * |
||
| 36 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
| 37 | */ |
||
| 38 | public function user() |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Video relation. |
||
| 45 | * |
||
| 46 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
| 47 | */ |
||
| 48 | public function video() |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Return all instances when type is likes. |
||
| 55 | * |
||
| 56 | * @param $query |
||
| 57 | * |
||
| 58 | * @return mixed |
||
| 59 | */ |
||
| 60 | 8 | public function scopeLikes($query) |
|
| 64 | |||
| 65 | /** |
||
| 66 | * Return all instances when type is dislikes. |
||
| 67 | * |
||
| 68 | * @param $query |
||
| 69 | * |
||
| 70 | * @return mixed |
||
| 71 | */ |
||
| 72 | 8 | public function scopeDislikes($query) |
|
| 76 | } |
||
| 77 |