/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //User::create(['email' => '*****@*****.**', 'password' => Hash::make('test')]); //Auth::logout(); $posts = Post::with('category')->Published()->get(); return view('posts.index', compact('posts')); }
public function getFeed($type = null) { $feed = App::make('feed'); //$feed->setCache(60); $parsedown = new Parsedown(); $parsedown->setMarkupEscaped(true); if (!is_null($type)) { $posts = Post::where('feed', $type)->with('user')->orderBy('created_at', 'desc')->take(20)->get(); } else { $posts = Post::with('user')->orderBy('created_at', 'desc')->take(20)->get(); } $pubDate = count($posts) == 0 ? date('Y-m-d H:i:s') : $posts[0]->created_at; $feed->title = 'rhofma.de - Blog'; $feed->description = 'Web-Developer Blog'; $feed->logo = asset('img/logo.svg'); $feed->link = URL::to('/'); $feed->setDateFormat('datetime'); $feed->pubdate = $pubDate; $feed->lang = 'de'; $feed->setShortening(true); $feed->setTextLimit(500); foreach ($posts as $post) { $feed->add($post->title, $post->user->name, URL::to($post->slug), $post->created_at, $text = $post->teaser, $parsedown->parse($post->content)); } return $feed; }
public function getIndex() { $posts = Cache::remember('site.overboard', 60, function () { return Post::with('op', 'board', 'board.assets')->withEverything()->orderBy('post_id', 'desc')->take(75)->paginate(15); }); return $this->view(static::VIEW_MULTIBOARD, ['posts' => $posts]); }
public function getData($id, $title, $kode) { $dateNow = Carbon::now(); $kelasDosen = Perkuliahan::select('kodekelas')->where('nip', '=', $id)->get()->toArray(); $data = array('dosen' => DB::table('dosen')->where('nip', $id)->first(), 'dosenProfile' => Dosen::where('nip', '=', Request::segment(3))->first(), 'kelas' => Mhskelas::with(array('mhs', 'perkuliahan', 'mk'))->where('nim', '=', $id)->get(), 'kelasDosen' => Perkuliahan::with(array('mk', 'dosen'))->where('nip', '=', $id)->get(), 'title' => $title, 'listPerkuliahan' => ['' => '-- Pilih kelas --'] + Mhskelas::select('matakuliah.namamk', 'mhskelas.kodekelas')->join('matakuliah', 'mhskelas.kodemk', '=', 'matakuliah.kodemk')->join('mahasiswa', 'mhskelas.nim', '=', 'mahasiswa.nim')->where('mahasiswa.nim', '=', $id)->lists('matakuliah.namamk', 'mhskelas.kodekelas'), 'perkuliahanDosen' => ['' => '-- Pilih kelas --'] + Perkuliahan::select('perkuliahan.kodekelas', 'matakuliah.namamk')->join('matakuliah', 'matakuliah.kodemk', '=', 'perkuliahan.kodemk')->where('perkuliahan.nip', '=', $id)->lists('matakuliah.namamk', 'perkuliahan.kodekelas'), 'grup' => AnggotaGrup::select('grup.nama', 'grup.kodekelas')->join('grup', 'grup.id', '=', 'anggota_grup.id_grup')->where('anggota_grup.nim', '=', $id)->get(), 'post' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('creator', '=', $id)->get(), 'postKelas' => Post::with(array('komentar', 'mhs', 'perkuliahan'))->where('id_scope', '=', $kode)->get(), 'kelasMember' => Mhskelas::with('mhs')->where('kodekelas', '=', $kode)->get(), 'infokelas' => Perkuliahan::with('mk', 'dosen')->where('kodekelas', '=', $kode)->first(), 'tugasDosen' => Tugas::where('pengumpulan', '>=', $dateNow)->whereIn('kelas', $kelasDosen)->get(), 'pengumumanDosen' => Pengumuman::where('waktuaktif', '>=', $dateNow)->whereIn('kodekelas', $kelasDosen)->get()); return $data; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $user = Sentinel::findById($id); $activation = Activation::exists($user); $posts = Post::with(['thread', 'thread.category'])->where('user_id', $user->id)->orderBy('created_at', 'desc')->get(); return view('admin.users.show', compact('user', 'activation', 'posts')); }
/** * Show the application dashboard to the user. * * @return Response */ public function index() { $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->orderBy('created_at', 'desc')->take(4)->get(); $mostPopular = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->take(4)->get(); $communities = Community::all(); $cities = City::all(); return view('pages.home', ['posts' => $posts, 'mostPopular' => $mostPopular, 'communities' => $communities, 'cities' => $cities]); }
/** * Display all looks by User * * @return Response */ public function looks($userId) { if (!User::find($userId)) { throw new NotFoundHttpException('no user found'); } $looks = Post::with(['location', 'brands', 'look', 'post_author', 'comments', 'comments.comment_author'])->where('user_id', $userId)->where('is_look', true)->get(); return response()->json($looks); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $post = Post::with(['location', 'photos', 'brands', 'look', 'post_author', 'comments', 'comments.comment_author'])->where('id', $id)->get(); if (!$post || !count($post)) { throw new NotFoundHttpException('no post found'); } return response()->json($post); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($slug) { $tag = Tag::where('slug', $slug)->firstOrFail(); $posts = Post::with('tags')->whereHas('tags', function ($q) use($tag) { $q->where('tag_id', $tag->id); })->orderBy('created_at', 'desc')->paginate(15); return view('tags.show', compact('tag', 'posts')); }
public function index() { $totallikes = Like::count(); $totalposts = Post::count(); $posts = Post::with('cat', 'likes')->paginate(config('app.posts_per_page')); $page = $posts->currentPage(); $lastpage = $posts->lastPage(); return view('index', compact('totallikes', 'totalposts', 'posts', 'page', 'lastpage', 'title')); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $req = Post::with('user')->with('category')->with('job')->orderBy('updated_at', 'desc'); if ($request->has('filterBy')) { $req->where($request->get('filterBy') . '_id', $request->get('id')); } $posts = $req->get(); return view('admin.posts.index', compact('posts')); }
/** * Display a listing of the resource. * * @return Response */ public function index(Subreddit $subreddit, Post $post, Moderator $moderator, User $user) { //$posts = Post::with('user.votes')->get(); $posts = Post::with('user.votes')->with('subreddit.moderators')->orderBy('created_at', 'desc')->get(); //$ids = $posts->subreddit; $isModerator = false; //dd($ids); return view('home')->with('posts', $posts)->with('isModerator', $isModerator); }
public function showPost($slug, Request $request) { $post = Post::with('tags')->whereSlug($slug)->firstOrFail(); $tag = $request->get('tag'); if ($tag) { $tag = Tag::whereTag($tag)->firstOrFail(); } return view($post->layout, compact('post', 'tag')); }
/** * Display a listing of the resource. * * @param Request $request * @return Response */ public function index(Request $request) { if ($id = $request->get('tag')) { $tag = Tag::findOrFail($id); return $tag->posts()->with('tags')->get(); } else { return Post::with('tags')->latest()->take(5)->get(); } }
/** * Display single post */ public function getDetail($id, $page) { $post = Post::with('get_category')->find($id); if ($page == 'unpublished') { return view('admin/post/detailPost', array('user' => $this->username, 'nav_post' => '', 'nav_list_post' => '', 'post' => $post, 'page' => $page)); } elseif ($page == 'published') { return view('admin/post/detailPost', array('user' => $this->username, 'nav_post' => '', 'nav_pub_post' => '', 'post' => $post, 'page' => $page)); } }
public function sitemap() { $sitemap = App::make("sitemap"); $sitemap->add(URL::to('/'), date('Y-m-d'), '1.0', 'daily'); $posts = Post::with('user')->orderBy('created_at', 'desc')->get(); foreach ($posts as $post) { $sitemap->add(URL::to($post->slug), $post->created_at, '0.9', 'weekly'); } return $sitemap->render('xml'); }
public function showPost($slug, Request $request, ShortenLink $shortenLink) { $post = Post::with('tags')->whereSlug($slug)->firstOrFail(); $tag = $request->get('tag'); $link = $shortenLink->shortenUrl($request->url()); $shortLink = $link->getShortUrl(); if ($tag) { $tag = Tag::whereTag($tag)->firstOrFail(); } return view($post->layout, compact('post', 'tag', 'slug', 'shortLink')); }
function _postsRelationships() { return Post::with(['user' => function ($query) { $query->select('id', 'user_name'); }, 'tags' => function ($query) { $query->select('name'); }, 'comments' => function ($query) { $query->with(['user' => function ($q) { $q->select('id', 'user_name'); }]); }]); }
public function index() { $posts = Post::with('discuss')->orderBy('published_at', 'desc')->paginate(config('blog.posts_per_page')); //分页配置 // $discuss =Post::find(2)->discuss()->get(); // $dis_count = Post::all()->discuss(); // $posts->with('discusss'); //dd($posts); return view('admin.discuss.index', compact('posts')); //分页 //return view('admin.discuss.index',compact('posts')); }
public function comment(Request $request, $id) { $post = Post::with(["comments", "comments.user"])->findOrFail($id); $comment = $post->comments()->create(["content" => $request->content]); if (!Auth::check() || $request->anonymous != "") { $comment->user_id = null; } else { $comment->user_id = Auth::user()->id; } $comment->save(); echo $request->anonymous; return redirect("/post/{$id}"); }
public function index(Request $request) { $posts = Post::with('likes', 'cat')->paginate(config('app.posts_per_page')); if ($request->ajax()) { if ($posts) { if ($posts->currentPage() <= $posts->lastPage() && $posts->total() > config('app.posts_per_page')) { return response()->json(['result' => true, 'page' => $posts->currentPage(), 'lastpage' => $posts->lastPage(), 'html' => view('ajax.pagination', array('posts' => $posts))->render()]); } } return response()->json(['result' => false]); } return view('posts.index', compact('posts')); }
public static function view_data(Request $request, Post $post) { $instance = new Self(); $per_page = session('per_page') ? session('per_page') : config('constants.per_page'); $post = Post::with('user.votes')->with('subreddit.moderators')->with('comments')->where('id', $post->id)->first(); $comment = $post->comments; $user = User::where('id', '=', Auth::id())->get(); $check = $post->subreddit->moderators->where('user_id', Auth::id())->first(); $isModerator = $check ? true : false; $result['per_page'] = $per_page; $result['comments'] = $instance->comment_list($per_page, $request, $post, $comment, $user, $isModerator); $result['total_comments'] = $instance->total_comments($post); return $result; }
public function getHistory($ip = null) { if (!$this->user->canViewRawIP()) { return abort(403); } if (is_null($ip)) { return abort(404); } try { $ip = new IP($ip); } catch (\InvalidArgumentException $e) { return abort(404); } catch (\Exception $e) { throw $e; } $posts = Post::with('op', 'board', 'board.assets')->withEverything()->where('author_ip', $ip)->orderBy('post_id', 'desc')->paginate(15); return $this->view(static::VIEW_HISTORY, ['posts' => $posts]); }
public function filter(Request $request) { $allCommunities = $request->communities; $communities = Community::where('city_id', $request->city)->get(); $requestedInfo = $request; if ($request->from == '' || $request->from == 0) { $from = 1.0E+17; } else { $from = $request->from; } if (sizeof($allCommunities) > 0) { $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->whereBetween('price', array($request->to, $from))->whereIn('community_id', $allCommunities)->where('city_id', $request->city)->paginate(12); } else { $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->whereBetween('price', array($request->to, $from))->where('city_id', $request->city)->paginate(12); } $city = City::where('id', $request->city)->get(); return view('city.home', ['posts' => $posts, 'city' => $city, 'communities' => $communities, 'request' => $requestedInfo]); }
public function getPosts($slug = null, $groupId = 0) { $posts = Post::with('comments', 'user'); if (Input::has('term')) { $term = '%' . Input::get('term') . '%'; $posts = $posts->where('title', 'like', $term)->orWhere('content', 'like', $term)->orWhere('teaser', 'like', $term); } if (!is_null($slug)) { $user = User::where('slug', $slug)->first(); $posts = $posts->where('user_id', $user->id); } if ($groupId > 0) { $posts = $posts->where('group_id', $groupId)->orderBy('position', 'asc'); } else { $posts = $posts->orderBy('created_at', 'desc'); } $posts = $posts->paginate(10); return $posts; }
public static function getCache($channel = null) { $cacheKey = 'last200' . $channel . 'posts'; if (!Cache::has($cacheKey)) { // if no cache exists if (is_null($channel)) { // if all posts (no channel) $tempPosts = Post::with('source')->with('scores')->orderBy('publishing_date', 'desc')->take(200)->get()->chunk(20); } else { // channel $tempPosts = Channel::where('shorthand', $channel)->first()->posts()->with('source')->with('scores')->orderBy('publishing_date', 'desc')->take(200)->get()->chunk(20); } // if no results, return false if ($tempPosts->count() == 0) { return false; } // If all ok, cache results for 10 minutes Cache::put($cacheKey, $tempPosts, 10); } return Cache::get($cacheKey); }
/** * Display the user dashboard * */ public function dashboard() { // Get user data to display $user = Auth::user(); $job_list = array('paladin' => 'Paladin', 'monk' => 'Monk', 'warrior' => 'Warrior', 'dragoon' => 'Dragoon', 'bard' => 'Bard', 'ninja' => 'Ninja', 'white-mage' => 'White Mage', 'black-mage' => 'Black Mage', 'scholar' => 'Scholar', 'summoner' => 'Summoner', 'dark-knight' => 'Dark Knight', 'machinist' => 'Machinist', 'astrologian' => 'Astrologian'); // Have a look for any posts that mention the user $mention_posts = collect(); if ($user->character_name) { $character_name = explode(' ', $user->character_name); $mention_posts = Post::with('thread')->with('user')->where('content', 'like', '%@' . $character_name[0] . '%')->orWhere('content', 'like', '%@' . $character_name[0] . $character_name[1] . '%')->orderBy('created_at', 'DESC')->limit(5)->get(); } // Get the latest topics // Get the users permissions $accessCollection = $user->forumAccess; $latest_posts = Post::with('thread')->with('user')->whereIn('forum_id', $accessCollection)->orderBy('created_at', 'DESC')->limit(7)->get(); if ($user->hasRole('administrators')) { $group_list = Role::all(); $group_array = array(); foreach ($group_list as $group) { $group_array[$group->id] = $group->display_name; } $permission_list = Permission::all(); $permission_array = array(); foreach ($permission_list as $permission) { $permission_array[$permission->id] = $permission->display_name; } $users_list = User::all(); $users_array = array(); foreach ($users_list as $users) { $users_array[$users->id] = $users->character_name ? $users->character_name : $users->name; } $forums_list = Forum::orderBy('display_order', 'asc')->get(); return view('user.dashboard')->withUser($user)->withMentionPosts($mention_posts)->withLatestPosts($latest_posts)->withJobList($job_list)->withGroupList($group_list)->withGroupArray($group_array)->withPermissionArray($permission_array)->withUsersArray($users_array)->withForumList($forums_list); } else { return view('user.dashboard')->withUser($user)->withJobList($job_list)->withMentionPosts($mention_posts)->withLatestPosts($latest_posts); } }
/** * Return data for normal index page * * @return array */ protected function normalIndexData() { $posts = Post::with('tags')->where('published_at', '<=', Carbon::now())->where('is_draft', 0)->orderBy('published_at', 'desc')->simplePaginate(config('blog.posts_per_page')); return ['title' => config('blog.title'), 'subtitle' => config('blog.subtitle'), 'posts' => $posts, 'page_image' => config('blog.page_image'), 'meta_description' => config('blog.description'), 'reverse_direction' => false, 'tag' => null]; }
public function update(EditPostRequest $request, Post $post) { $post = Post::with('user.votes')->with('subreddit.moderators')->findOrFail($post->id); $ids = $post->subreddit; $isModerator = $ids->moderators()->where('user_id', Auth::id())->exists(); if (Gate::denies('update-post', [$post, $isModerator])) { return redirect('subreddit')->withErrors('You cannot edit this post.'); } else { $post->update($request->all()); return redirect('/subreddit'); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { return App\Post::with('user.likes')->find($id); }