I have 2 ways to reach the destination
Approach : 1
$ProjectBid = \App\Models\Project\Bids\ProjectBid_Model
::with('WhoPlacedBid')
->with(['Project' => function($query){
$query->where('WhoCreatedTheProject', auth()->user()->UserID);
}])
->with('Project.WhoCreatedProject')
->where('EmployerReviewGiven', 0)
->where('FreelancerAwardedProjectStatusID', '4')
->orwhere('FreelancerAwardedProjectStatusID', '5')
->get();
Approach : 1 produces following query
select B.*, P.* from `tblprojectbid` as `B`
inner join `tblproject` as `P` on `B`.`projectid` = `P`.`projectid`
where `B`.`EmployerReviewGiven` = ? and `P`.`WhoCreatedTheProject` = ?
and `B`.`FreelancerAwardedProjectStatusID` = ?
or `B`.`FreelancerAwardedProjectStatusID` = ?
Approach : 2
$ProjectBid = \App\Models\Project\Bids\ProjectBid_Model
::with('WhoPlacedBid')
->with(['Project' => function($query){
$query->where('WhoCreatedTheProject', auth()->user()->UserID);
}])
->with('Project.WhoCreatedProject')
->where('EmployerReviewGiven', 0)
->where('FreelancerAwardedProjectStatusID', '4')
->orwhere('FreelancerAwardedProjectStatusID', '5')
->get();
Approach : 2 produces following queries
Approach : 2 First Query
select * from tblprojectbid
where EmployerReviewGiven = ? and `FreelancerAwardedProjectStatusID` = ?
or `FreelancerAwardedProjectStatusID` = ?
Approach : 2 Second Query
select * from tblusers where tblusers.UserID in (?)
Approach : 2 Third Query
select * from tblproject where tblproject.ProjectID in (?)
Approach : 2 Fourth Query
select * from tblusers where tblusers.UserID in (?)
Question:
Which approach should be followed ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire