Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. @foreach($authUser->reviews as $review)
  2. <p>{{ $review->body }} - {{$review->from_user }}</p>
  3. @endforeach
  4.  
  5. class User extends Model implements AuthenticatableContract,
  6. AuthorizableContract,
  7. CanResetPasswordContract
  8. {
  9. use Authenticatable, Authorizable, CanResetPassword, Messagable;
  10.  
  11. protected $table = 'users';
  12.  
  13. protected $fillable = ['name', 'email', 'password', 'firstname', 'lastname', 'straat', 'postcode', 'plaats', 'provincie', 'role', 'specialisatie'];
  14.  
  15. protected $hidden = ['password', 'remember_token'];
  16.  
  17. public function projects()
  18. {
  19. return $this->hasMany('AppProject');
  20. }
  21.  
  22. public function reviews()
  23. {
  24. return $this->hasMany('AppReview');
  25. }
  26.  
  27. public function comments()
  28. {
  29. return $this->hasMany('AppComment');
  30. }
  31. }
  32.  
  33. <?php
  34.  
  35. namespace App;
  36.  
  37. use IlluminateDatabaseEloquentModel;
  38.  
  39. class Review extends Model
  40. {
  41. protected $guarded = [];
  42.  
  43. protected $table = 'reviews';
  44.  
  45. public function User()
  46. {
  47. return $this->belongsTo('AppUser');
  48. }
  49. }
  50.  
  51. <?php
  52.  
  53. namespace App;
  54.  
  55. use IlluminateDatabaseEloquentModel;
  56.  
  57. class Review extends Model
  58. {
  59. protected $guarded = [];
  60.  
  61. protected $table = 'reviews';
  62.  
  63. public function user()
  64. {
  65. return $this->belongsTo('AppUser', 'from_user');
  66. }
  67. }
  68.  
  69. @foreach($authUser->reviews as $review)
  70. <p>{{ $review->body }} - {{ $review->user->name }}</p>
  71. @endforeach
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement