I have three tables
service_cats (id - cat_name)
service_sub_cats (id - cat_id - sub_cat_name)
sub_cat_contents (id - sub_cat_id - title - content)
and I made this relations
serviceCat
public function serviceSubCat()
{
return $this->hasMany('ServiceSubCat');
}
serviceSubCat
public function ServicesCat()
{
return $this->belongsTo('ServiceCat', 'cat_id');
}
public function ssContent()
{
return $this->hasMany('SubCatContent');
}
subCatContent
public function ssCat()
{
return $this->belongsTo('ServiceSubCat', 'sub_cat_id');
}
I need to grape data from the three tables to use them.
here is my controller
public function show($id)
{
$serCat = ServiceCat::where('id', $id)->first();
$getId = $serCat->sub_status;
if ($getId == 1) {
$subCats = ServiceSubCat::with('ssContent')->where('cat_id', $id)->get();
//dd($subCats);
return View::make('portal.services.servicesDetailsList', compact('serCat', 'subCats'));
} else {
return View::make('portal.services.servicesDetails');
}
}
now I get Error
Column not found
I need to get the cat_name, sub_cat_name, title, content