【发布时间】:2019-06-21 01:32:03
【问题描述】:
我需要一些帮助。本质上,有两个表(tblplayers & tblmatches)。并非每个玩家都存在于 tblmatches 中。我的控制器有这个代码:
use App\Model\Players;
use App\Model\Matches;
use Illuminate\Support\Facades\DB;
class PlayersController extends Controller
{
public function index(Request $request) {
$players = Players::select('*');
我想更改上面的 select 语句,使其仅返回也存在于 tblmatches 中的玩家(其中 tblmatches.P1_ID = tblplayers.ID)。
我在下面做错了什么?
$players = Players::addSelect(DB::raw('(SELECT * from tblmatches where (P1_ID = ID))'));
我应该改换型号吗?感谢您的帮助。
【问题讨论】:
标签: php laravel laravel-5 filter