Laravel Eloquent relationship error -


i'm using laravel 5 blog. when use relation "hasmany", got following error "fatalerrorexception in 45abc28f0139bedaa1467307304d448ffaaed95e.php line 5: syntax error, unexpected '->' (t_object_operator) "

here postcontroller

<?php   namespace app\http\controllers;   use illuminate\http\request;  use illuminate\view;  use app\http\requests;  use app\post;    class postcontroller extends controller { public function index(){     $listeposts = post::all();      return view('post.index', compact('listeposts')); }  public function show($detail){     $post = post::where('detail', $detail)->firstorfail();     $author = $post->user;     $comment = $post->comments;      return view('post.show', compact('post', 'author', 'comment'));     }  }   ?> 

here post model

<?php   namespace app;   use illuminate\database\eloquent\model;    class post extends model { protected $guarded = ['id', 'created_at'];  public function user(){     return $this->belongsto('app\user'); }  public function comments(){     return $this->hasmany('app\comment'); } } 

and here user model

<?php   namespace app;    use illuminate\notifications\notifiable;   use illuminate\foundation\auth\user authenticatable;    class user extends authenticatable  { use notifiable;  /**  * attributes mass assignable.  *  * @var array  */ protected $guarded = ['id', 'created_at'];  protected $fillable = [     'user_full_name', 'user_pseudo', 'email', 'password', ];  /**  * attributes should hidden arrays.  *  * @var array  */ protected $hidden = [     'password', 'remember_token', ];   public function posts(){     return $this->hasmany('app\post'); }  public function comments(){     return $this->hasmany('app\comment'); }  } 

please, how can solve problem ?

thanks

here show.blade.php source code

@extends('template')  @section('content')  <div class="panel panel-primary"> <div class="panel-heading">     <h2 class="panel-title" align="center">{{post->post_name}}</h2>     <h3> créé par : {{author->user_pseudo}} |         @if (post->count_comments == 0)             pas de commentaire         @elseif (post->count_comments == 1)             1 commentaire         @else              {{ post->count_comments}} commentaires         @endif       </h3> </div> <div class="panel-body">     <p>{{post->content}}</p>      <div>         <h2 class="label label-info">les commentaires</h2>         @foreach($comment $onecomment)             <h4>posté par : {{ $onecomment->user->user_pseudo}}</h4>             <p>{{ $onecomment->content}}</p>         @endforeach     </div> </div>     </div>   @stop 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -