Skip to content

Instantly share code, notes, and snippets.

@ambrizals
Last active September 5, 2017 11:19
Show Gist options
  • Save ambrizals/6296e15c7be1d7323ec49078720fd8b8 to your computer and use it in GitHub Desktop.
Save ambrizals/6296e15c7be1d7323ec49078720fd8b8 to your computer and use it in GitHub Desktop.
Error : 2
public function CategoryArticle(){
return $this->belongsTo('App\CategoryArticle','kategori_article','id_category');
}
public function viewArticle($slug_article){
$article = Article::where('slug_article', $slug_article)->first()->with('Article.CategoryArticle')->get();
$halaman = 'blog';
return view('article.show', compact('article','halaman'));
}
public function CategoryArticle(){
return $this->hasMany('App\Article');
}
@foreach ($article as $item)
<h2>{!! $item->judul_article !!}</h2>
{!! $item->konten_article !!}
{!! $item->CategoryArticle->nama_kategori !!}
@endforeach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment