Rjonwal
2 weeks ago
162
9
General

laravel getting data from two tables

Posted 2 weeks ago by Rjonwal

Someone please help me ,

i want to get data from two tables

table first => contest

table second = > contest_details

relationship => one to many

contest hasMany ContestDetail

I'm using this function but getting error

    $referralContests = Contest::where([['type', '=', 'referral'], ['start_date', '>', $current_date]])->whereHas('contestDetail', function ($query) use ($this->id){
        $query->where('contest_id ', $this->id);
    })->get();

error : Symfony\Component\Debug\Exception\FatalThrowableError syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ')' or ','

help me.

Please sign in or create an account to participate in this conversation.