Database One table row —
id | District |
---|---|
1 | Dhaka |
2 | Ctg |
3 | Comilla |
Another Table row have —
id | Library name |
---|---|
1 | Comilla |
2 | Ctg |
3 | Dhaka |
How i query Data in a laravel 8 Model, Controller, Blade with in a loop like Below —-
Table Two Re-order within Table One “District” Serial Order —-
id | District |
---|---|
1 | Dhaka |
2 | Ctg |
3 | Comilla |
Here is my laravel Code in controller
public function AllStaffAdd(){
$penyedia = AriaInfoSl::all();
$staff_adds = StaffAdd::with('area_information_serial')->get();
return view('admin.tsign.staff_add.index' , compact('penyedia', 'staff_adds'));
}
My Model One —
public function area_information_serial()
{
return $this->hasMany(AriaInfoSl::class, ‘district’, ‘id’);
}
My Model Two —
public function area_information_serial()
{
return $this->belongsTo(StaffAdd::class, ‘staff_library_name’, ‘id_no’);
}
But not show Data Properly …
Md. Billal Hossain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.