how to get whole object in laravel Eloquent with many tables?(Database Structure Updated)

Product Model protected $fillable = [‘name’,’brand_id’,’sort’]; public function brands() { return $this->belongsTo(‘App\Brands’,’brand_id’); } public function sub_attributes() { return $this->hasMany(‘App\SubAttributes’,’id’); } public function values() { return $this->hasMany(‘App\AttributesValue’,’product_id’); } Main Attribute Model protected $fillable = [‘name’]; public function product() { return $this->belongsTo(‘App\Product’); } public function sub_attribute() { return $this->hasMany(‘App\SubAttributes’,’main_attribute_id’); } public function attributes_value() { return $this->hasManyThrough(‘App\AttributesValue’,’App\SubAttributes’); }…

Laravel – How to get Row with 2 column?

I want to show a list of materi (table), based on 2 values from 2 columns. and the column is : kelas (from user table) nama_mapel (from mapel table) but in materi is just “mapel” not nama_mapel. My StudentController : public function showMateriList($id) { $user = Auth::user(); $mapel = mataPelajaran::findOrFail($id); $materis = Materi::where(‘kelas’, ‘=’, Auth::user()->kelas)…