skip to Main Content

Laravel local scope with hasMany relation

I have a Laravel model Product and Vouchers defined as follows: class Product extends Model { public function vouchers(): HasMany { return $this->hasMany(Voucher::class); } } and class Voucher extends Model { public function product(): BelongsTo { return $this->belongsTo(Product::class); } }…

VIEW QUESTION

Laravel Eloquent add a WHERE xy IS NULL condition

I use Laravel 10. I try to fetch some data from my mariaDB with the following condition. $contentList = $this->get(); foreach($contentList as $content){ $this->product()->where('id', '=', $content->content_product_id)->ddRawSql(); } But the query I get is: select * from `radio_content_products` where `radio_content_products`.`id` is…

VIEW QUESTION
Back To Top
Search