I am using rss feed service with laravel 5.3
I have implemented service in controller as below:
public function index()
{
$news = News::with('user')->orderBy('created_at', 'desc')->take(4)->get();
$feed = App::make('feed');
// $feed->id = 'My blog';
// $feed->title = 'My blog';
// $feed->description = 'This is my blog about this';
// // $feed->logo = asset('img/logo.png'); //optional
// $feed->link = url('feed');
// $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon'
// $feed->pubdate = $news[0]->created_at;
// $feed->lang = 'en';
// $feed->setShortening(true); // true or false
// $feed->setTextLimit(100); // maximum length of description text
foreach ($news as $post)
{
// set item's title, author, url, pubdate, description and content
$feed->add($post->title, $post->user->name, url('posts/' . $post->id), $post->created_at, $post->description, $post->description,['user_id'=>$post->id, 'photo'=>$post->photo]);
}
$news = $feed->render('rss'); // or atom
return view('home',compact(['news']));
}
and iterate feed items in blade view:
<link rel="alternate" type="application/rss+xml" title="My blog" href="" />
@foreach($news->original->items as $new)
<div class="blog-item">
<img class="img-responsive img-blog" src="/images/newsphotos/" width="100%" alt="" />
<div class="blog-content">
<a href="blog-item.html"><h3></h3></a>
<div class="entry-meta">
<span><i class="icon-user"></i> <a href="#"></a></span>
<span><i class="icon-folder-close"></i> <a href="#">Bootstrap</a></span>
<span><i class="icon-calendar"></i> </span>
</div>
<p>
</p>
<a class="btn btn-default" href="">Read More <i class="icon-angle-right"></i></a>
</div>
</div><!--/.blog-item-->
@endforeach
It looks fine, the thing is I search on the net browsers can recognize ress services and let users "subscribe" but my browsers all unawera of this information..
How can I make this subscribable by browsers ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire