title: "Undefined variable $exams (View: /Users/pathparakh/Projects/relationship/resources/views/marks/create.blade.php)" in Laravel Relationship
body: <p>This Is My &quot;Mark&quot; Model.   I have 3 model linked with this model.</p>
  <pre><code>use HasFactory;
  
  protected $table = 'marks';
  
  protected $fillable = [
      'subject_id',
      'student_id',
      'exam_id',
      'mark',
  ];
  
  public function exams() {
      return $this-&gt;belongsTo(Exam::class);
  }
  
  public function students() {
      return $this-&gt;belongsTo(Student::class);
  }
  
  public function subjects() {
      return $this-&gt;belongsTo(Subject::class);
  }
  </code></pre>
  <p>This Is My Exam Model. this is linked with Mark model</p>
  <pre><code>use HasFactory;
  
  protected $table = &quot;exams&quot;;
  
  protected $fillable = [
      'exam',
  ];
  
  public function marks() {
      return $this-&gt;hasMany(Mark::class);
  }
  </code></pre>
  <p>This Is My MarkController. This is my controller in which 3 model are linked</p>
  <pre><code>public function index()
  {
      $marks = Mark::all();
      $students = Student::all();
      $subjects = Subject::all();
      $exams = Exam::all();
      return view('marks.index', compact('marks', 'students', 'subjects', 'exams'));
  }
  
  /**
   * Show the form for creating a new resource.
   *
   * @return \Illuminate\Http\Response
   */
  public function create()
  {
      return view('marks.create');
  }
  </code></pre>
  <p>This is my marks.create where error is occurring in line 20</p>
  <pre><code>&lt;td&gt;
      &lt;select name=&quot;exam_id&quot; id=&quot;exam_id&quot; class=&quot;form-control&quot;&gt;
          &lt;option value=&quot;&quot;&gt;Select One&lt;/option&gt;
          @foreach ($exams as $exam)
          &lt;option value=&quot;{{ $exam-&gt;id }}&quot;&gt;{{ $exam-&gt;name }}&lt;/option&gt;
          @endforeach
      &lt;/select&gt;
  &lt;/td&gt;
  </code></pre>