src/Traits/Periodable.php
public function scopeActiveOn($query, $period)
    {
        return $query->whereHas('periods', function($query) use ($period){
            $query->where('academic_periods_id', $period);
        });
    }
public function scopeActiveOn($query, $period)
    {
        return $query->whereHas('periods', function($query) use ($period){
            $query->where('academic_periods_id', $period);
        });
    }
public function scopeActiveOn ( $ query , $ period ) { return $ query -> whereHas ( 'periods' , function ( $ query ) use ( $ period ) { $ query -> where ( 'academic_periods_id' , $ period ) ; } ) ; }
Only studies active for given period.

@param \Illuminate\Database\Eloquent\Builder $query
@param $period
@return mixed
Only studies active for given period .