/** * Execute the console command. * * @return mixed */ public function handle() { $sources = Source::all(); foreach ($sources as $source) { $feed = Feeds::make($source->feed_url); $items = $feed->get_items(); foreach ($items as $item) { $article = Article::firstOrNew(['link' => $item->get_permalink()]); $article->source_id = $source->id; $article->title = $item->get_title(); $article->content = $item->get_description(); if ($item->get_date()) { $article->date = Carbon::createFromFormat('j F Y, g:i a', $item->get_date()); } else { $article->date = Carbon::now(); } if (!empty($article->content)) { // Disable HTML 5 related errors libxml_use_internal_errors(true); $doc = new DOMDocument(); $doc->loadHTML($article->content); $imageTags = $doc->getElementsByTagName('img'); foreach ($imageTags as $tag) { $src = $tag->getAttribute('src'); if (strpos($src, ".jpg") or strpos($src, ".png") or strpos($src, ".jpeg")) { $article->image_url = $src; break; } } } $article->save(); } } }
/** * Execute the console command. * * @return mixed */ public function handle() { // If a shorthand is given if ($this->argument('shorthand')) { $this->getPostsFromSource($this->argument('shorthand')); return; } // else $sources = Source::all(); foreach ($sources as $key => $source) { try { $this->getPostsFromSource($source->shorthand); } catch (Exception $e) { $this->error('There was a problem with source [ ' . $source->description . ' ]'); } } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $sources = Source::all(); return view('admin.sources.index')->with('sources', $sources); }
public function postSources() { return Source::all(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // Get all sources $sources = Source::all(); return view('sources.index', compact('sources')); }