示例#1
0
<script type="text/javascript">
        $(function () {
            $("textarea").wysihtml5();
        });
</script>

@stop

@section('title')
    @if(isset($category->name))
        {!! $category->name !!} -
    @endif
@stop

@section('category')
<h2 class="section-title h4 clearfix">{!! Lang::get('lang.categories') !!}<small class="pull-right"><i class="fa fa-hdd-o fa-fw"></i></small></h2>
<ul class="nav nav-pills nav-stacked nav-categories">

<?php 
$categorys = App\Model\kb\Category::all();
?>
    @foreach($categorys as $category)
<?php 
$num = \App\Model\kb\Relationship::where('category_id', '=', $category->id)->get();
$article_id = $num->lists('article_id');
$numcount = count($article_id);
?>
    <li><a href="{{url('category-list/'.$category->slug)}}"><span class="badge pull-right">{{$numcount}}</span>{{$category->name}}</a></li>
    @endforeach
</ul>
@stop
 public function getCategory($slug, Article $article, Category $category, Relationship $relation)
 {
     /* get the article_id where category_id == current category */
     $catid = $category->where('slug', $slug)->first();
     $id = $catid->id;
     $all = $relation->where('category_id', $id)->get();
     // $all->setPath('');
     /* from whole attribute pick the article_id */
     $article_id = $all->lists('article_id');
     $categorys = $category->get();
     /* direct to view with $article_id */
     return view('themes.default1.client.kb.article-list.category', compact('all', 'id', 'categorys', 'article_id'));
 }
 /**
  * Edit an Article by id
  * @param type Integer $id
  * @param type Article $article
  * @param type Relationship $relation
  * @param type Category $category
  * @return Response
  */
 public function edit($slug, Article $article, Relationship $relation, Category $category)
 {
     $aid = $article->where('id', $slug)->first();
     $id = $aid->id;
     /* define the selected fields */
     $assign = $relation->where('article_id', $id)->lists('category_id');
     /* get the attributes of the category */
     $category = $category->lists('id', 'name');
     /* get the selected article and display it at edit page  */
     /* Get the selected article with id */
     $article = $article->whereId($id)->first();
     /* send to the edit page */
     return view('themes.default1.agent.kb.article.edit', compact('assign', 'article', 'category'));
 }