コード例 #1
0
 /**
  * Hämtar vy tillsammans med dynamisk Yajra-table
  * @param  Request $request AJAX 
  * @return articles.blade.php, (html-kod)
  */
 public function index(Request $request)
 {
     if ($request->ajax()) {
         $articles = ArticlesList::select("*")->get();
         return Datatables::of($articles)->editColumn('name', function ($article) {
             return '<a href="/article/' . $article->id . '/show">' . $article->name . '</a>';
         })->make(true);
     }
     $html = $this->htmlBuilder->addColumn(['data' => 'id', 'name' => 'id', 'title' => '#'])->addColumn(['data' => 'article_id', 'name' => 'article_id', 'title' => 'Artikelnr'])->addColumn(['data' => 'name', 'name' => 'name', 'title' => 'Benämning'])->addColumn(['data' => 'unit', 'name' => 'unit', 'title' => 'Enhet']);
     return view("article.articles", compact('html'));
 }