那麼我想做到這一點,基本上我有一個表稱爲遊戲具有獲得兩個用戶名
creator_id
和 guest_id
現在我想做的是當我要列出所有的比賽我要加入兩個表,並得到例如,如果creator_id
是約翰和guest_id
是瑪麗
我想列出所有的「遊戲」與他們的名字
ID:322 |創建者姓名:John |客人姓名:瑪麗
等等,這是我走到這一步:
控制器:
class AdminController extends Controller
{
public function index()
{
return view('admin.home');
}
public function listGames()
{
$games = Game::get();
return view('admin.games.list', compact('games'));
}
}
查看:
@extends('admin.content')
@section('title', 'List games')
@section('content')
<table class="table table-hover">
@foreach($games as $game)
// now i want to list that here
@endforeach
</table>
@endsection
放模型與你的問題及其相互關係碼 –
請檢查下面 – Cadilab