コード例 #1
0
 public function index()
 {
     //        $posts = Post::all();
     //        $posts = Post::orderBy('created_at', 'desc')->get();
     $posts = Post::latest('created_at')->get();
     dd($posts->toArray());
     return view('posts.index');
 }
コード例 #2
0
ファイル: PostsController.php プロジェクト: shawon922/blog
 public function index()
 {
     $page_title = 'This is HomePage';
     $posts = Post::latest('published_at')->published()->get();
     $posts = Post::paginate(5);
     //dd($posts);
     return view('posts.index', compact('page_title', 'posts'));
 }
コード例 #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $limit = Input::get('limit') ?: 5;
     $posts = Post::latest('published_at')->paginate($limit);
     //        dd(get_class_methods($posts));
     return $this->respond(['data' => $this->postTransformer->transformCollection($posts->all()), 'paginator' => ['total_count' => $posts->total(), 'current_page' => $posts->currentPage(), 'total_pages' => ceil($posts->total() / $posts->perPage()), 'limit' => $posts->perPage()]]);
 }
コード例 #4
0
 public function index($profile = null)
 {
     if ($profile != null) {
         $posts = $profile->posts()->latest()->paginate(20);
     } else {
         $posts = Post::latest()->paginate(20);
     }
     return view('admin.post.index', compact('posts', 'profile'))->with(['title' => 'Post Management']);
 }
コード例 #5
0
 function index()
 {
     $user = Auth::user();
     $posts = Post::latest('id')->get();
     $companies = Company::all();
     $users = User::all();
     $testvar = "XYZABC";
     return view('users.test', compact('testvar'));
     return view('users.index', compact('user', 'posts', 'companies', 'users'));
 }
コード例 #6
0
 public function index()
 {
     // $posts = \App\Post::all();
     // $posts = Post::all();
     // $posts = Post::orderBy('created_at', 'desc')->get();
     $posts = Post::latest('created_at')->get();
     // dd($posts->toArray()); // dump to die
     // $posts = [];
     // return view('posts.index', ['posts' => $posts]);
     return view('posts.index')->with('posts', $posts);
 }
コード例 #7
0
ファイル: DashboardController.php プロジェクト: emadmrz/Hawk
 public function index()
 {
     $latestArticles = Article::latest()->take(6)->get();
     $latestPosts = Post::latest()->take(6)->get();
     $latestProblems = Problem::latest()->take(6)->get();
     $latestGroups = Group::latest()->take(6)->get();
     $latestUsers = User::latest()->take(6)->get();
     $ratedUsers = User::orderBy('rate', 'desc')->take(6)->get();
     $chartDatas = Comment::select([DB::raw('DATE(created_at) AS date'), DB::raw('COUNT(id) AS count')])->groupBy('date')->orderBy('date', 'ASC')->get()->toArray();
     return view('admin.dashboard.index', compact('latestArticles', 'latestPosts', 'latestProblems', 'latestGroups', 'latestUsers', 'ratedUsers', 'chartDatas'))->with(['title' => 'Admin Dashboard Panel']);
 }
コード例 #8
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer(['includes.footer.mainfooter', 'includes.snellepage'], function ($view) {
         $view->with('diensten', Dienst::all());
     });
     view()->composer('includes.personen', function ($view) {
         $view->with('users', User::where('role_id', '1')->take(3)->get());
     });
     view()->composer('includes.recensies.klanten', function ($view) {
         $view->with('recensies', Recensie::where('uitgelicht', '1')->get());
     });
     view()->composer('includes.sidebar.groot', function ($view) {
         $view->with('posts', Post::latest('published_at')->published()->get()->take(5));
     });
 }
コード例 #9
0
ファイル: PagesController.php プロジェクト: nehero/updoot
 public function getIndex()
 {
     if (Auth::check()) {
         $posts = Post::latest()->get();
         foreach ($posts as $key => $value) {
             if (!Auth::user()->subdoots->contains($value->subdoot->id)) {
                 unset($posts[$key]);
             }
         }
     } else {
         $posts = Post::latest()->get();
     }
     $filter = "new";
     return view('index', compact('filter', 'posts'));
 }
コード例 #10
0
 public function team()
 {
     $lastSliders = Slider::latest()->take(1)->get();
     $lastPosts = Post::latest()->take(2)->get();
     $lastEvents = Event::latest()->take(2)->get();
     $title = 'Equipo';
     $lastEvents2 = Event::latest()->skip(2)->take(2)->get();
     return view('guest.team')->with('title', $title)->with('lastPosts', $lastPosts)->with('lastEvents', $lastEvents)->with('lastEvents2', $lastEvents2)->with('lastSliders', $lastSliders);
 }
コード例 #11
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $post_all = Post::latest()->published()->paginate(5);
     //get one to many
     $post = Post::find(11);
     if ($post) {
         $comments = $post->comments()->get();
     }
     //$comments->posts()->where('active', 1)->get();
     //$comments = Post::find(11)->comments()->where('title', 'foo')->first();
     //inverse
     $comment = Comment::find(1);
     if ($comment) {
         $post_found = $comment->post->title;
     }
     //many to many
     $user = User::find(32);
     if ($user) {
         $roles = $user->roles;
     }
     //$roles2 = User::find(11)->roles()->orderBy('role')->get();
     //Has Many Through
     $country = Country::find(1);
     $post_by_country = $country->posts;
     //Polymorphic
     //foreach ($post->likes as $like) {}
     //inverse
     $like = Like::find(1);
     if ($like) {
         $likeable = $like->likeable;
     }
     //Many To Many Polymorphic
     //$post = App\Post::find(1);
     //foreach ($post->tags as $tag) {}
     //inverse
     $tag = Tag::find(1);
     //Querying Relationship Existence
     // Retrieve all posts that have at least one comment...
     //$posts = Post::has('comments')->get();
     // Retrieve all posts that have three or more comments...
     $posts = Post::has('comments', '>=', 3)->get();
     // Retrieve all posts that have at least one comment with votes...
     //$posts = Post::has('comments.votes')->get();
     // Retrieve all posts with at least one comment containing words like foo%
     // $posts = Post::whereHas('comments', function ($query) {//orWhereHas
     //     $query->where('content', 'like', 'foo%');
     // })->get();
     //Eager loading
     $post2 = Post::with('user')->get();
     //Eager Loading Multiple Relationships
     //Sometimes you may need to eager load several different relationships in a single operation. To do so, just pass additional arguments to the with method:
     //$books = Post::with('user', 'publisher')->get();
     //Nested Eager Loading
     //To eager load nested relationships, you may use "dot" syntax. For example, let's eager load all of the book's authors and all of the author's personal contacts in one Eloquent statement:
     //$books = App\Book::with('author.contacts')->get();
     //Constraining Eager Loads
     //Sometimes you may wish to eager load a relationship, but also specify additional query constraints for the eager loading query. Here's an example:
     // $users = App\User::with(['posts' => function ($query) {
     //     $query->where('title', 'like', '%first%');
     // }])->get();
     //In this example, Eloquent will only eager load posts that if the post's title column contains the word first. Of course, you may call other query builder to further customize the eager loading operation:
     // $users = App\User::with(['posts' => function ($query) {
     //     $query->orderBy('created_at', 'desc');
     // }])->get();
     //Lazy Eager Loading
     //Sometimes you may need to eager load a relationship after the parent model has already been retrieved. For example, this may be useful if you need to dynamically decide whether to load related models:
     //$books = App\Book::all();
     // if ($someCondition) {
     //     $books->load('author', 'publisher');
     // }
     //If you need to set additional query constraints on the eager loading query, you may pass a Closure to the load method:
     // $books->load(['author' => function ($query) {
     //     $query->orderBy('published_date', 'asc');
     // }]);
     return view('posts.index', compact('post', 'comments', 'post_found', 'user', 'roles', 'roles2', 'country', 'post_by_country', 'likeable', 'tag', 'post2', 'post_all'));
 }
コード例 #12
0
 public function index()
 {
     $posts = Post::latest()->paginate(20);
     return view("backend.post.index", ["posts" => $posts]);
 }
コード例 #13
0
 /**
  * Display a listing of the auth resource.
  *
  * @return Response
  */
 public function postsAuth()
 {
     $limit = Input::get('limit') ?: 2;
     $posts = Post::latest('updated_at')->where('user_id', '=', Auth::user()->id)->paginate($limit);
     return view('posts.postsAuth', compact('posts'));
 }
コード例 #14
0
ファイル: PostsController.php プロジェクト: nickdunn2/bitter
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Post::latest()->paginate(10);
 }
コード例 #15
0
 public function get($count = 10)
 {
     return Post::latest()->paginate($count);
 }
コード例 #16
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Post::latest()->take(5)->get();
     return view('posts.index', ['posts' => $posts]);
 }
コード例 #17
0
ファイル: PostController.php プロジェクト: Jimbol4/blog
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $posts = Post::latest()->get();
     return view('posts.index', compact('posts'));
 }
コード例 #18
0
 public function index()
 {
     $posts = \App\Post::latest('published_at')->paginate(3);
     $tags = \App\Tag::all();
     return view('frontend.pages.blog')->with('posts', $posts)->with('tags', $tags);
 }
コード例 #19
0
ファイル: PostController.php プロジェクト: andyzulu/mini-cms
 public function adminIndex(request $request)
 {
     $posts = Post::latest('published_at')->get();
     return view('post.admin-index')->with('posts', $posts);
 }
コード例 #20
0
 /**
  * Show all last posts.
  *
  * @param  int  $id
  * @return Response
  */
 public function showAll()
 {
     $lastPosts = Post::latest()->get();
     return view('posts.posts')->with('lastPosts', $lastPosts);
 }
コード例 #21
0
 public function home()
 {
     $posts = Post::latest()->published()->take(16)->get();
     $categoryPosts = Category::all();
     return view('pages.index', compact('posts', $posts, 'categoryPosts', $categoryPosts));
 }
コード例 #22
0
ファイル: routes.php プロジェクト: Gadurp1/KD-2
    $photo = \App\Image::latest()->take(1)->lists('url');
    return view('images.theatre')->with('photo', $photo);
});
/*
|-------------------------------------------------------------------------
| App Routes
|--------------------------------------------------------------------------
*/
//  Blog Routes
Route::get('post', 'PostController@index');
Route::get('admin/post', 'PostController@index');
Route::get('Cat-Gifs', 'ImageController@index');
Route::get('Cat-Gifs/{id}', 'ImageController@show');
Route::get('Cat-Gifs/{id}/embed', 'ImageController@embed');
Route::get('api/posts', function () {
    $posts = \App\Post::latest()->get();
    return $posts;
});
Route::get('post/{slug}', 'PostController@show');
// Coupon Routes
Route::get('cases', 'CouponsController@index');
Route::get('cases/{slug}', 'CouponsController@show');
// Page Routes
Route::get('pages/{slug}', 'PagesController@show');
/*
|-------------------------------------------------------------------------
| Admin  Routes
|--------------------------------------------------------------------------
*/
Route::get('admin', 'AdminController@index');
Route::get('home', 'AdminController@index');
コード例 #23
0
 /**
  * Display the specified resource.
  *
  * @param  Category $category
  * @return \Response
  */
 public function show($category)
 {
     $posts = Post::latest()->where('category_id', $category->id)->with(['category', 'author'])->paginate(20);
     return view(Route::currentRouteName(), compact('category', 'posts'));
 }
コード例 #24
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $posts = Post::latest()->get();
     return view('posts.all')->with(['posts' => $posts, 'new_notifications_count' => Auth::user()->notifications()->unread()->get()->count(), 'notifications' => Auth::user()->notifications()->not_type('message')->get(), 'new_messagesNotifications_count' => Auth::user()->notifications()->unread()->type('message')->get()->count(), 'messagesNotifications' => Auth::user()->notifications()->type('message')->get()]);
 }
コード例 #25
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('partials.nav', function ($view) {
         $view->with('latest', Post::latest('updated_at')->first());
     });
 }
コード例 #26
0
 /**
  * Display a listing of the resource.
  *
  * @return \Response
  */
 public function index()
 {
     $posts = Post::latest()->with(['category', 'author'])->paginate(20);
     return view(Route::currentRouteName(), compact('posts'));
 }
コード例 #27
0
ファイル: Blog.php プロジェクト: gomessimon/velblog
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //return "index";z
     $posts = Post::latest('created_at')->get();
     return view('blog', compact('posts'));
 }
コード例 #28
0
 /**
  * Bind data to the view.
  *
  * @param View $view
  */
 public function compose(View $view)
 {
     $posts = Post::latest()->take(5)->get();
     $view->with('lastPosts', $posts);
 }
コード例 #29
0
 public function getAllCategoriesPosts()
 {
     $allPosts = Post::latest()->published()->paginate(10);
     return view('pages.posts.category_posts', compact('allPosts', $allPosts));
 }
コード例 #30
0
ファイル: Post.php プロジェクト: centaurustech/vivala
 /**
  * Retorna os posts ordenados por data ignorando a relevancia e os
  * followers 
  */
 public static function getUltimos()
 {
     return Post::latest()->get();
 }