コード例 #1
0
 /**
  * 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'));
 }
コード例 #2
0
ファイル: FeedService.php プロジェクト: rhofma/rhofma.de
 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;
 }
コード例 #3
0
 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]);
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 /**
  * 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'));
 }
コード例 #6
0
ファイル: HomeController.php プロジェクト: jakeboyles/GuyBuy
 /**
  * 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]);
 }
コード例 #7
0
 /**
  * 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);
 }
コード例 #8
0
 /**
  * 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);
 }
コード例 #9
0
 /**
  * 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'));
 }
コード例 #10
0
ファイル: HomeController.php プロジェクト: majid-n/cometdev
 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'));
 }
コード例 #11
0
ファイル: PostsController.php プロジェクト: e-noumene/Back
 /**
  * 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'));
 }
コード例 #12
0
 /**
  * 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);
 }
コード例 #13
0
ファイル: IndexController.php プロジェクト: canwonson/myWeb
 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'));
 }
コード例 #14
0
 /**
  * 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();
     }
 }
コード例 #15
0
 /**
  * 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));
     }
 }
コード例 #16
0
ファイル: BlogController.php プロジェクト: rhofma/rhofma.de
 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');
 }
コード例 #17
0
 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'));
 }
コード例 #18
0
 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');
         }]);
     }]);
 }
コード例 #19
0
ファイル: DiscussController.php プロジェクト: boosb/test
 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'));
 }
コード例 #20
0
ファイル: PostController.php プロジェクト: yyc/cvwblag
 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}");
 }
コード例 #21
0
ファイル: PostController.php プロジェクト: majid-n/cometdev
 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'));
 }
コード例 #22
0
 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;
 }
コード例 #23
0
 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]);
 }
コード例 #24
0
ファイル: CityController.php プロジェクト: jakeboyles/GuyBuy
 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]);
 }
コード例 #25
0
ファイル: PostService.php プロジェクト: rhofma/rhofma.de
 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;
 }
コード例 #26
0
ファイル: Post.php プロジェクト: aboustayyef/deprecated_lb_l5
 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);
 }
コード例 #27
0
ファイル: UserController.php プロジェクト: unbolt/imp
 /**
  *  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);
     }
 }
コード例 #28
0
ファイル: BlogIndexData.php プロジェクト: guduchango/l5beauty
 /**
  * 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];
 }
コード例 #29
0
 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');
     }
 }
コード例 #30
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return App\Post::with('user.likes')->find($id);
 }