Zeigen Sie JSON-Daten in der Laravel-Ansicht mit Join-Tabellen eins als Referenztabelle anPhp

PHP-Programmierer chatten hier
Anonymous
 Zeigen Sie JSON-Daten in der Laravel-Ansicht mit Join-Tabellen eins als Referenztabelle an

Post by Anonymous »

Kann jemand helfen? Ich wollte Spalten aus Join-Tabellen in der Laravel-Ansicht anzeigen. Eine bestimmte Spalte enthält JSON-Daten.
Tabelle:

ref_code_exam



< tr>
id
Beschreibung



1
Prüfung 1


2
Prüfung 2


3
Prüfung 3


ref_appointment



< tr>
id
registry_id
type_of_exam_id




1
10
2

2
11
["1","2","3"]




Code in mein Controller:
$data = $this->data();

$array = array();

foreach ($data as $v) {
$apptype1[] = $v->type_of_exam_id

$array[$v->id] = array(
'type_of_app' => array()
);

$type_of_app = DB::table('ref_code_exam')
->wherein('id', $apptype1)
->get();

foreach ($type_of_app as $k) {
array_push($array[$v->id]['type_of_app'], $k->description);
}
}

return view('transactions.pendapp', ['data' => $data, 'apptype1' => $array])
->with('i', (request()->input('page', 1) -1) * 10);

View Controller:
@foreach($data as $students)

{{ ++$i }}
{{ $students->applicant_no }}
{{ $students->stud_fname }}
{{ $students->stud_mname }}
{{ $students->stud_lname }}
{{-- {{ $students->description}} --}}

@foreach ($apptype1[$students->id] as $v)
@for ($m = 0; $m < count($v); $m++)
[*]{{ $v[$m] }}
@endfor
@endforeach


In der Spalte „Prüfungstyp“ werden jedoch alle Prüfungstypen aufgelistet, auch wenn nur ein Prüfungstyp ausgewählt ist.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post