Support the ongoing development of Laravel.io →
Laravel Requests Database

I want to do relation in laravel with this database, what I wanted to happen is I can access all the data from **ReportProduct **Model

database

what i have done is to relation one at a time:

**ReportProduct **Model:

public function product()
{
    return $this->hasMany(Product::class, 'product_id', 'product_id');
}
public function store()
{
    return $this->hasMany(Store::class, 'store_id', 'store_id');
}

Store Model:

public function storing()
 {
     return $this->hasManyThrough(StoreAccount::class, StoreArea::class, 'area_id', 'account_id', 'account_id', 'area_id');
 }

Product Model:

public function productBrand()
{
    return $this->hasmany(ProductBrand::class,'brand_id','brand_id');
}

public function report(){
    return $this->belongsTo(ReporttProduct::class,'product_id','product_id');
}

What i wanted to do is, how to get all data from store and product through report_product only with relation. thank you in advance!

alirasouliwebdeveloper liked this thread

1

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.