Level 88
What have you tried so far?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 3 tables. stocks, products, purchase_items.
Stock Model:
protected $fillable = ['product_id', 'product_code_id', 'quantity'];
public function code()
{
return $this->belongsTo(ProductCode::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
PurchaseItem Model:
protected $fillable = ['product_id', 'product_code_id', 'quantity'];
public function code()
{
return $this->belongsTo(ProductCode::class);
}
public function product()
{
return $this->belongsTo(Product::class);
}
Product Model:
protected $fillable = ['id', 'name'];
public function purchaseItems()
{
return $this->hasMany(PurchaseItem::class);
}
I want to get data from Stocks table with today's purchased quantity which will filter by product_code, product_id
Please or to participate in this conversation.