Support the ongoing development of Laravel.io →
Database Eloquent Views
Last updated 2 years ago.
0

This is the solution from an IRC user JasonLewis

public function scopeCityName($query)
{
    return $query
        ->join('cities', 'cities.id', '=', 'realestates.city_id')
        ->join('city_translations', 'cities.id', '=', 'city_translations.city_id')
        ->join('languages', 'city_translations.language_id', '=', 'languages.id')
        ->where('languages.code','=',Session::get('my.lang'))
        ->where('realestates.id','=',$this->id)
        ->select('city_translations.name as name')->pluck('name');
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

mabasic mabasic Joined 3 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.