From 780c67102f516375bc515e9eb925a12a2d314221 Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Thu, 21 Mar 2024 11:32:43 +0100 Subject: [PATCH] Fix per vista menu --- src/Models/Module.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Models/Module.php b/src/Models/Module.php index fa3f228ef..5a27b2f93 100755 --- a/src/Models/Module.php +++ b/src/Models/Module.php @@ -177,9 +177,13 @@ class Module extends Model public function children() { - return $this->hasMany(self::class, 'parent')->withoutGlobalScope('enabled') + return $this->hasMany(self::class, 'parent') + ->withoutGlobalScope('enabled') ->selectRaw('zz_modules.*, zz_modules_lang.title as title') - ->join('zz_modules_lang', 'zz_modules.id', '=', 'zz_modules_lang.id_record') + ->join('zz_modules_lang', function ($join) { + $join->on('zz_modules.id', '=', 'zz_modules_lang.id_record') + ->where('zz_modules_lang.id_lang', '=', \Models\Locale::getDefault()->id); + }) ->orderBy('order'); } @@ -201,13 +205,16 @@ class Module extends Model public static function getHierarchy() { return self::with('allChildren') - ->selectRaw('zz_modules.*, zz_modules_lang.title as title') - ->join('zz_modules_lang', 'zz_modules.id', '=', 'zz_modules_lang.id_record') + ->select('zz_modules.*', 'zz_modules_lang.title as title') + ->join('zz_modules_lang', function ($join) { + $join->on('zz_modules.id', '=', 'zz_modules_lang.id_record') + ->where('zz_modules_lang.id_lang', '=', \Models\Locale::getDefault()->id); + }) ->withoutGlobalScope('enabled') ->whereNull('parent') ->orderBy('order') ->get(); - } + } protected static function boot() {