0
$serviceId = Service::select('id')->where('provider_id', Auth::user()->id)->where('is_deleted', 0);
$list = DB::table('service_galleries')
            ->where('is_deleted', 0)
            ->joinSub($serviceId, 'sid', function ($qry) {
                $qry->on('service_galleries.service_id', '=', 'sid.id');
            })->get();

From the above code I need id of every row in service galleries table but is return service_id in the field of id, which means service_id and id is same

1

1 Answer 1

0

Why dont you use Laravel's Eloquent built in relationships ? This could save you a lot of headaches.

For example in your Service model you can create a function for example:

public function galleries(){
    $this->hasMany(ServiceGalleries::class);
}

And in your ServiceGalleries model (don't know the actual name)

public function service(){
    $this->belongsTo(Service::class);
}
Sign up to request clarification or add additional context in comments.

1 Comment

for performance time. ex: laravel do where exists when is slower than a join.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.