php - Laravel Fluent Query - property of non-object -


i working on displaying user active jobs , pending interviews on dashboard. can active jobs work, when try display pending interviews jobs, error: "trying error of non-object." error line: $jobinterviews->id

here dashboard view:

@if (! $active)             <p> don't have active projects. click here post one!  </p>              @else                 @foreach($active $job)             <div class="media-body">                      display $job name/description                     </div>                     @if ($jobinterviews->id == $active->id)                     <table class="table table-striped">                         display $jobinterviews details                   </table>                     @else                     <p></p>                         @endif             </div> <!-- .media-body -->                     @endforeach             @endif          </div> <!-- .media --> 

i have run through @foreach loop $active , $jobinterviews separately , both work fine. when nest @if ($jobinterviews->id == $active->id), error "attempting display property of non object" related $jobinterviews->id

here controller method:

public function getdashboard()     {      //reading user information     $arrpagedata['user'] = sentry::getuser();      //reading job interviews     $arrpagedata['jobinterviews'] = jobinterview::readcurrentinterviews($this->userid);             //reading active jobs     $arrpagedata['active'] = job::activejobs($this->userid);      return view::make('clients.dashboard', $arrpagedata);     } 

and finally, here query statements:

 public static function readcurrentinterviews($jobid){     return db::table('jobs')                 ->join('job_interviews', 'job_interviews.job_id', '=', 'jobs.id')                 ->join('contractors', 'contractors.user_id', '=', 'job_interviews.send_to')                 ->where('jobs.user_id', '=', $jobid)                  ->where('job_interviews.status', '=', 'awaiting response')                 ->orderby('job_interviews.created_at', 'desc')                 ->select('jobs.id','jobs.title', 'contractors.user_id', 'contractors.contact_name', 'job_interviews.status', 'jobs.created_at')                 ->get(); }    public static function activejobs($contractorid){    return db::table('jobs')         ->where('user_id', '=', $contractorid)         ->select('id','title', 'description', 'created_at')         ->get(); } 

if knows why non-object error being thrown, appreciate understanding it. thank in advance.

just change following:

@if ($jobinterviews->id == $active->id) 

to this:

@if ($jobinterviews->id == $job->id) 

here $active array of models.

also make sure $jobinterviews not array of models , if it's array of models $jobinterviews->id not work. it's:

foreach($jobinterviews $jobinterview)     ...     foreach($active $job)     @if ($jobinterview->id == $job->id)         ...     @endforeach @endforeach 

in view $jobinterviews , $active both array of multiple models , using $jobinterviews->id or $active->id not work, instead have select individual item them.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -