Quantcast
Channel: Displaying feeds and blogs according to the created time - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Displaying feeds and blogs according to the created time

$
0
0

I'm having a home page where all the feeds along with comments and blogs are being displayed. Right now it is showing first all the feeds and then the blog. But I want it should be displayed according to the created time, mixer of feeds and blog not like first feed will come and then the blog. Can anyone tell me how to acheive that. This is my index.blade.php

@extends('layouts/default'){{-- Page title --}}@section('title')Home@parent@stop{{-- page level styles --}} @section('header_styles')<!--page level css starts--><link rel="stylesheet" type="text/css" href="{{ asset('assets/css/frontend/action.css') }}"><link rel="stylesheet" type="text/css" href="{{ asset('assets/css/frontend/tabbular.css') }}"><link rel="stylesheet" type="text/css" href="{{ asset('assets/css/frontend/jquery.circliful.css') }}"><link rel="stylesheet" type="text/css" href="{{ asset('assets/vendors/owl.carousel/css/owl.carousel.css') }}"><link rel="stylesheet" type="text/css" href="{{ asset('assets/vendors/owl.carousel/css/owl.theme.css') }}"><!--end of page level css-->@stop{{-- content --}}@section('content')<div class="row"><div class="column col-md-1 col-xs-1 col-sm-1"></div><div class="column col-md-3 col-xs-3 col-sm-3"><!--gm-editable-region--> </div><div class="column col-md-4 col-xs-4 col-sm-4">       @include ('action.partials.form')       @include ('action.partials.error')       @include ('action.partials.feed')       @include ('action.partials.blogfeed')</div><div class="column col-md-3 col-xs-3 col-sm-3"><!--gm-editable-region--></div><div class="column col-md-1 col-xs-1 col-sm-1"></div>

@stop{{-- footer scripts --}}@section('footer_scripts')<!-- page level js starts--><script type="text/javascript" src="{{ asset('assets/js/frontend/jquery.circliful.js') }}"></script><script type="text/javascript" src="{{ asset('assets/vendors/owl.carousel/js/owl.carousel.min.js') }}"></script><script type="text/javascript" src="{{ asset('assets/js/frontend/carousel.js') }}"></script><script type="text/javascript" src="{{ asset('assets/js/frontend/index.js') }}"></script><!--page level js ends-->@stop

This is action.partials.feed

@foreach($feeds as $feed)<article class="media"><div class="well"><div class="pull-left"> <img class="profile" src="{{ URL::to('/uploads/users/'.$feed->user->pic)  }}" class="img-responsive" alt="Image" style="width:48px;height:48px;padding-right : 10px;padding-bottom: 5px;"></div><strong>{{ $feed->user->first_name }}                 {{ $feed->user->last_name }}<small> posted </small></strong>                {{ $feed->created_at->diffForHumans() }}<br><hr>                {{ $feed->feed_content }}<hr>            {!! Form::open(['url' => 'home/{storecomment}']) !!}<div><input type="hidden" name="feed_id" value="{{ $feed->feed_id }}" /></div><div class="form-group">                    {!! Form::text('comment', null, ['class'=>'form-control', 'rows'=>3, 'placeholder'=>"Comment"]) !!}</div><div class="form-group feed_post_submit"><a href="/home">{!! Form::submit('Comment', ['class' => 'btn btn-default btn-xs']) !!}</a></div>            {!! Form::close() !!}            @foreach($feed->comments as $comment)<div class="pull-left"> <img class="profile" src="{{ URL::to('/uploads/users/'. $comment->user->pic)  }}" class="img-responsive" alt="Image" style="width:48px;height:48px;padding-right : 10px;padding-bottom: 5px;"></div>                {{ $comment->user->first_name }}                 {{ $comment->created_at->diffForHumans() }}                {{ $comment->comment }}<hr>            @endforeach</div></article>@endforeach

action.partials.blogfeed

@foreach($blogs as $blog)<article class="media"><div class="well"><div class="pull-left"> <img class="media-object" src="{{ URL::to('/uploads/users/'.$blog->user->pic)  }}" class="img-responsive" alt="Image" style="width:48px;height:48px;padding-right : 10px;padding-bottom: 5px;"></div><strong>{{ $blog->user->first_name }}                 {{ $blog->user->last_name }}<small> posted blog</small></strong>                {{ $blog->created_at->diffForHumans() }}<br><hr><h4><a href="{{ URL::to('blogitem/'.$blog->slug) }}">{{ $blog->title }}</a></h4><div class="featured-post-wide thumbnail">                     @if($blog->image)<img src="{{ URL::to('/uploads/blog/'.$blog->image)  }}" class="img-responsive" alt="Image">                     @endif</div></div></article>@endforeach

This is my feedcontroller

<?phpnamespace App\Http\Controllers;use Request;use Auth;use Sentinel;use App\Feed;use App\Http\Requests;use App\Blog;use App\Http\Controllers\Controller;use App\Comment;class FeedsController extends Controller{    public function index() {  // $comments = Comment::latest()->get();  $feeds = Feed::with('comments', 'user')->where('user_id', Sentinel::getUser()->id)->latest()->get();   $blogs = Blog::latest()->simplePaginate(5);  $blogs->setPath('blog');  return view('action.index', compact('feeds', 'blogs'));}public function store(Requests\CreateFeedRequest $request){  $request->merge( [ 'user_id' => Sentinel::getuser()->id] );  Feed::create($request->all());  return redirect('home');} public function storecomment(Requests\CommentRequest $request, Feed $feed) {  $comment = new Comment;  $comment->user_id =Sentinel::getuser()->id;  $comment->feed_id = $request->feed_id;  $comment->comment = $request->comment;  $comment->save();  return redirect('/home');}  }

Can any one tell me how to display feeds and blogs according to the published time.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images