I need some help here. Essentially, there are two tables (tblplayers & tblmatches). Not every player exists in tblmatches. My controller has this code:
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('*');
I would like to change my select statement above so that it only returns players that also exist in tblmatches (where tblmatches.P1_ID = tblplayers.ID).
What am I doing wrong below?
$players = Players::addSelect(DB::raw('(SELECT * from tblmatches where (P1_ID = ID))'));
Should I be changing the model instead? Thanks for your help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire