第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Laravel 等效項中的未知列

Laravel 等效項中的未知列

PHP
猛跑小豬 2023-08-06 10:36:01
我是 Laravel 的初學者。我的 mysql 有問題。我有這個代碼:模型:    class Product extends Model    {        use ScopeActiveTrait;        use Slugable;            public function setNameAttribute($value)        {            $this->attributes['name'] = $value;            $this->attributes['slug'] = $this->makeSlug($value);        }            protected $fillable = ['delivery_time', 'product_type', 'name', 'title', 'description', 'keywords', 'content', 'vat_id', 'main_category_id', 'enable', 'slug', 'small_description'];        protected $quarded = ['id'];        public $timestamps = false;            public function vat()        {            return $this->belongsTo('App\Models\VAT', 'vat_id');        }            public function category()        {            return $this->belongsTo('App\Models\Category', 'main_category_id');        }            public function selectedCategory()        {            return $this->hasMany('App\Models\SelectedProductCategory', 'product_id', 'id');        }            public function related()        {            return $this->belongsTo('App\Models\RelatedProduct');        }            public function features()        {            return $this->hasMany('App\Models\SelectedProductFeature');        }                public function frontImage()        {            return $this->hasMany('App\Models\UploadImage', 'file_id', 'id')->orderBy('order', 'ASC')->where('file_type', 'products');        }    }        class SelectedProductCategory extends Model    {        protected $fillable = ['product_id', 'category_id'];        protected $quarded = ['id'];    }
查看完整描述

1 回答

?
慕容708150

TA貢獻1831條經(jīng)驗 獲得超4個贊

改變這個


    public function getProductFromIdCategories($categories)

    {

        return $this->model->select('name', 'slug', 'products.id', 'small_description')

            ->with(['selectedCategory', 'frontImage', 'selectedCategory' => function($q) use ($categories){

                $q->whereIn('category_id', $categories);

            }])->whereIn('category_id', $categories)->active()->get();

    }

在此


    public function getProductFromIdCategories($categories)

    {

        return $this->model->select('name', 'slug', 'products.id', 'small_description')

            ->with(['frontImage', 'selectedCategory'])

            ->whereHas('selectedCategory', function ($q) use($categories) {

                $q->whereIn('category_id', $categories);

            })->active()->get();

    }


查看完整回答
反對 回復 2023-08-06
  • 1 回答
  • 0 關注
  • 96 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號