-1

This is my code:

 $evaluationjob = evaluation_elements_jobs::where('job_id', $user->job_id)
          ->where('company_id',$company_check->id)
          ->first();

The error in this line:

         $items = json_decode($evaluationjob["element_degree"]);

The error message is:

Trying to access array offset on value of type null

1
  • check if $evaluationjob["element_degree"] is null Commented Feb 16, 2022 at 9:41

2 Answers 2

0

You can try this:

$evaluationjob = evaluation_elements_jobs::where('job_id', $user->job_id)
      ->where('company_id',$company_check->id)
      ->first();

if ($evaluationjob != null && isset($evaluationjob["element_degree"])) {
    $items = json_decode($evaluationjob["element_degree"]);
}

This will check if $evaluationjob is not null and if the value $evaluationjob["element_degree"] exists in the variable.

Sign up to request clarification or add additional context in comments.

Comments

0

The error you are having here is the fact that you're trying to access a property on a variable that is null;

So you need to put a check on the variable and the property.

if ($evaluationjob != null && isset($evaluationjob["element_degree"])) {
    $items = json_decode($evaluationjob["element_degree"]);
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.