fork download
  1. <?php
  2.  
  3. //метод в модели subjects
  4. public function marks()
  5. {
  6. return $this->belongsToMany('App\Marks');
  7. }
  8.  
  9. //метод в модели students
  10. public function marks()
  11. {
  12. return $this->belongsToMany('App\Marks');
  13. }
  14.  
  15. //метод в контроллере SubjectsController
  16. public function show(Subjects $subject)
  17. {
  18. $students = Marks::where('subject_id', $subject->id)->get();
  19.  
  20. dd($students);
  21. }
Runtime error #stdin #stdout #stderr 0.02s 24140KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Parse error:  syntax error, unexpected 'public' (T_PUBLIC), expecting end of file in /home/QkLgUk/prog.php on line 4