Laravel code

having relation withCount Condition 

$mahasiswas = \App\Mahasiswa::Aktif()
->select('nim','nama')
->withCount('kelasmahasiswakrs')
->orderBy('kelasmahasiswakrs_count', 'desc')
->having('kelasmahasiswakrs_count','>',7)
->get()

has relation withCount

$mahasiswas = \App\Mahasiswa::Aktif()
->select('nim','nama')
->has('kelasmahasiswakrs')
->withCount('kelasmahasiswakrs')
->orderBy('kelasmahasiswakrs_count', 'desc')
->get()

edit content image path 

protected $appends = ['content'];

    public function getContentAttribute(){
        return preg_replace("/(src=\")(.*)(\/*.*\/*.*)/", "$1http://adifahram.space$2", $this->isi );
    }