I am writing an assignment system for biodata record. The data tables:
preceptorids
preceptorids_id | bio_id | preceptors_status
----------------| ---------------------------
1 | 5 | 3
bios
bio_id | bio_thana | boi_chaya | bio_name | bio_lastname | wat_stay
-------|-----------|------------|-----------|-------------------------
5 | 8 | chantha | harry | potter | 7
wats
id | wat_name | district
---|-------------|------------
7 | watsothorn | namuang
thana
thans_id | tname
---------| -----
8 | Mr
status
status_id | preceptors
----------| -----
3 | published
The controller for Assignment.add is as follows: which i will use it for select and save bio id to preceptorids //i am not sure that is this good way for laravel or not
$preceptor = DB::table('preceptorids')
->join('bios', 'preceptorids.bio_id', '=', 'bios.bio_id')
->join('wats', 'bios.bio_wat_stay', '=', 'wats.id')
->join('thana', 'bios.bio_thana', '=', 'thana.thana_id')
->select('bios.bio_wat_stay', 'thana.tname', 'bios.bio_chaya', 'bios.bio_name', 'bios.bio_lastname', 'wats.wat_name', 'wats.wat_district_id', 'wats.wat_amphurs_id', 'wats.wat_provinces_id','preceptorids.preceptors_status')
->where('preceptors_status', '=', 1)
->pluck('bio_chaya', 'preceptorids_id');
Expected Result : Frontend
tname | bio_name | bio_chaya | bio_lastname | wat_name | district | preceptors_status |
-------|------------|-----------|---------------|------------|------------|-------------------|
Mr | harry | chantha | potter | watsothorn | namuang | published |
Expected Result : Backend
<select>
<option value="1">Mr harry chantha potter watsothorn</option>
</select>
but when i dd($preceptor); it show only bio_chaya not preceptorids_id
Collection {#369 ▼
#items: array:1 [▼
"" => "chantha"
]
}
I'm new with laravel so any given guide will be so awesome.