Trying to get property 'course_id' of non-object