/** * Run the database seeds. * * @return void */ public function run() { $articlesJson = File::get(storage_path() . "/jsondata/news.json"); $articles = json_decode($articlesJson); foreach ($articles as $article) { Article::create(array('type' => $article->type, 'url' => $article->url, 'media_id' => $article->mediaId, 'title' => $article->title, 'summary' => $article->summary, 'posted' => $article->posted, 'author' => $article->author, 'source' => $article->source)); } }
/** * Home page * @return view */ public function home() { $articles = Article::whereType('youtube')->get(); return view('home', compact('articles')); }
/** * Articles Page accessed at /articles * @return view */ public function index() { $articles = Article::all(); return view('articles.index', compact('articles')); }