det här fungerade (ignorera de dynamiska sakerna som detta->getClassName etc.) den grundläggande logiken fungerar bra
public function scopeAddTranslations($query)
{
$t = new Translation();
$subq = $t->select('item','text as ref_ar')
->where('locale','=','ar')
->where('item','like',$this->getClassName().'.ref%');
$query->leftjoin(\DB::raw('('.$subq->toSql().') as t'),
function ($join) use ($subq) {
$join->on(\DB::raw('SUBSTRING('.$this->getTable().'.ref_translation
FROM 14 FOR 26)'),
'=',
\DB::raw('t.item'))
->addBinding($subq->getBindings());
});
return $query;
}