<commit_before><?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Video extends Model
{
    //

    protected $fillable = [
        'title', 'description', 'video_url', 'cover_url'
    ];

    public function author()
    {
        return $this->belongsTo('App\Models\Teacher', 'user_id');
    }

    public function comments()
    {
        return $this->hasMany('App\Models\Comment','video_id');
    }

    public function favoriteBy()
    {
        return $this->belongsToMany('App\Models\User','favorites','video_id','user_id');
    }

    public function series()
    {
        return $this->belongsTo('App\Models\Series', 'series_id');
    }

    public function scopeRecent($query, $limit = 30)
    {
        return $query->orderBy('created_at', 'desc')
            ->paginate($limit);
    }

    public function scopePopular($query, $limit = 30)
    {
        return $query->orderBy('watch_count','desc')
            ->paginate($limit);
    }
<commit_msg>add topPlayedPerSEries method<commit_after><?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Video extends Model
{
    //

    protected $fillable = [
        'title', 'description', 'video_url', 'cover_url'
    ];

    public function author()
    {
        return $this->belongsTo('App\Models\Teacher', 'user_id');
    }

    public function comments()
    {
        return $this->hasMany('App\Models\Comment', 'video_id');
    }

    public function favoriteBy()
    {
        return $this->belongsToMany('App\Models\User', 'favorites', 'video_id', 'user_id');
    }

    public function series()
    {
        return $this->belongsTo('App\Models\Series', 'series_id');
    }

    public function topPlayedPerSeries($limit = 30)
    {
        return $this->groupBy('series_id')->orderBy('watch_count', 'desc')
            ->paginate($limit);
    }

    public function scopeRecent($query, $limit = 30)
    {
        return $query->orderBy('created_at', 'desc')
            ->paginate($limit);
    }

    public function scopePopular($query, $limit = 30)
    {
        return $query->orderBy('watch_count', 'desc')
            ->paginate($limit);
    }
{'fraction_non_alphanumeric': 0.15299539170506912, 'fraction_numerical': 0.004608294930875576, 'mean_word_length': 2.66722972972973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7278775', 'n_tokens_mistral': 690, 'n_tokens_neox': 666, 'n_words': 123}