0
보기에서 상태 테이블의 데이터를 가져와야합니다. 앨리어스를 넣어 봤는데 3 시간 넘게 봤는데 길을 잃었 어. 어떤 아이디어?두 테이블이 laravel에서 보려는 데이터 전달에 합류합니다.
CONTROLER 코드 :
$action= DB::table('actionplan')
->join('status','actionplan.status','=','status.id')
->select('status.name as testas','actionplan.*')
->where([['user_id','=',$name],['done','<>',1]])->get();
보기 코드 :
@foreach($teams as $item)
<th scope="row">1</th>
<td>{{$item->name}}</td>
<td>{{$item->start_date}}</td>
<td>{{$item->end_date}}</td>
<td>{{$item->comment}}</td>
<td>{{$item->status()->name}}</td>
모델 간의 관계를 만들면 더 간단 해집니다. hasMany, hasOne, belongsTo 등 – Poria
@Poria 여기에는 모델이 없습니다. – apokryfos
코드에서 별칭을 정의하고 있지만 사용하고 있지는 않습니다. 그것은'{{$ item-> testas}}'' – apokryfos