芝麻web文件管理V1.00
编辑当前文件:/home/digitalh/yeahea.digitalhubbd.com/app/Models/CategorySubGroup.php
with(['translations' => function ($query) { $query->where('lang', app()->getLocale())->whereNotNull('translation'); }]); }); } /** * Get the categoryGroup that owns the SubGroup. */ public function group() { return $this->belongsTo(CategoryGroup::class, 'category_group_id')->withTrashed(); } /** * Get the categories for the CategorySubGroup. */ public function categories() { return $this->hasMany(Category::class, 'category_sub_group_id')->orderBy('order', 'asc'); } public function translations() { return $this->hasMany(CategorySubGroupTranslation::class); } // /** // * Get all listings for the category. // */ // public function getListingsAttribute() // { // return \DB::table('inventories') // ->join('category_product', 'inventories.product_id', '=', 'category_product.product_id') // ->select('inventories.*', 'category_product.category_id') // ->where('category_product.category_id', '=', $this->id)->get(); // // return $this->belongsToMany(Inventory::class, 'category_product', null, 'product_id', null, 'product_id'); // } /** * Setters */ public function setOrderAttribute($value) { $this->attributes['order'] = $value ?? 100; } public function hasTranslation($lang = null) { $lang = $lang ?? app()->getLocale(); if (!array_key_exists($lang, $this->translationExists)) { $this->translationExists[$lang] = $this->translations()->where('lang', $lang)->exists(); } return $this->translationExists[$lang]; } }