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
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!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community