コード例 #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function post_all(Request $request)
 {
     $user = $request->user();
     $posts = Post::where('author_id', $user->id)->orderBy('created_at', 'desc')->paginate(10);
     $title = $user->name;
     return view('frontend.post.show')->withPosts($posts)->withTitle($title);
 }
コード例 #2
0
 /**
  * Shows the specific user.
  * @param string $username
  * @return Response
  */
 public function show($username)
 {
     $post_upvotes = 0;
     $user = User::where('username', '=', $username)->firstOrFail();
     $user_posts = Post::where('user_id', '=', $user->id)->take(3)->get();
     foreach ($user_posts as $post) {
         $post->username = $user->username;
         $post->comment_count = Comment::where('post_id', '=', $post->id)->count();
         $post->hub_name = Hub::where('id', '=', $post->hub_id)->firstOrFail()->name;
         $post_upvotes = $post_upvotes + (int) $post->upvotes;
         $hub = Hub::find($post->hub_id);
         if (in_array($post->user_id, explode(',', $hub->moderators))) {
             $post->user_is_mod = true;
         } else {
             $post->user_is_mod = false;
         }
         $user = User::find($post->user_id);
         if ($user->is_admin) {
             $post->user_is_admin = true;
         } else {
             $post->user_is_admin = false;
         }
     }
     $comment_upvotes = 0;
     $user_comments = Comment::where('user_id', '=', $user->id)->take(3)->get();
     foreach ($user_comments as $comment) {
         $comment_upvotes = $comment_upvotes + (int) $comment->upvotes;
         $comment->email = md5($user->email);
     }
     return view('user.show', ['user' => $user, 'email' => md5($user->email), 'post_upvotes' => $post_upvotes, 'comment_upvotes' => $comment_upvotes, 'comments' => $user_comments, 'posts' => $user_posts]);
 }
コード例 #3
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;
 }
コード例 #4
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('posts', function (Blueprint $table) {
         $table->boolean('body_rtl')->nullable()->default(null)->after('body_html');
     });
     Post::where(DB::raw('1=1'))->update(['body_parsed' => null, 'body_parsed_at' => null, 'body_html' => null]);
 }
コード例 #5
0
 /**
  * Show post action, show one post. Search by slug first,
  * and if no result, search by id
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function getShowPost($id)
 {
     if (!($post = Post::where('slug', $id)->first())) {
         $post = Post::find((int) $id);
     }
     return view('front.showPost', compact('post'));
 }
コード例 #6
0
ファイル: UserController.php プロジェクト: kondipakamey/atofa
 public function showBoutiquePosts($user_id)
 {
     $user = $this->userRepository->getById($user_id);
     $posts = Post::where('user_id', '=', $user_id)->paginate($this->nbrPerPage);
     $links = str_replace('/?', '?', $posts->render());
     return view('manager.users.userPostList', compact('posts', 'user', 'links'));
 }
コード例 #7
0
ファイル: HomeController.php プロジェクト: y850830/lateall
 public function index()
 {
     $postType = '精選文章';
     $posts = \App\Post::where('is_feature', 1)->orderBy('created_at', 'desc')->paginate(5);
     $data = compact('postType', 'posts');
     return view('posts.index', $data);
 }
コード例 #8
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $posts = \App\Post::where('is_hot', true)->orderBy('created_at', 'desc')->paginate(5);
     $post_type = '熱門文章';
     $data = compact('posts', 'post_type');
     return view('posts.index', $data);
 }
コード例 #9
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $recipies = Post::where('postStatus_id', '=', 3)->get();
     Session::put('recipies', $recipies);
     $title = CmsOption::getValue('Название сайта');
     return view('home', ['recipies' => $recipies, 'title' => $title]);
 }
コード例 #10
0
 public function edit(Request $request, $id)
 {
     $post = Post::where('id', $id)->first();
     if ($post && $request->user()->id == $post->user_id) {
         return view('/edit')->with('post', $post);
     }
 }
コード例 #11
0
ファイル: UserController.php プロジェクト: jakeboyles/GuyBuy
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function showProfile($id)
 {
     $user = User::find($id);
     $posts = Post::where("user_id", $id)->get();
     $comments = Comment::where('user_id', $id)->get();
     return view('user.profile', ['user' => $user, 'comments' => $comments, 'posts' => $posts]);
 }
コード例 #12
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $is_student = Auth::user()->is_student;
     $color = $is_student ? '#3498db' : '#e74c3c';
     if ($is_student) {
         logger("学生アカウントナリ");
         $user = UserProfile::where('student_id', '=', Auth::user()->id)->first();
         if ($user === null) {
             // 学生用ページを表示
             $tech_items = ['Java' => 0, 'C' => 0, 'C++' => 0, 'Python' => 0, 'C#' => 0, 'Objective-C' => 0, 'Perl' => 0, 'HTML' => 0, 'CSS' => 0, 'JavaScript' => 0, 'PHP' => 0, 'Ruby' => 0, 'Scala' => 0];
             $tech = json_encode($tech_items);
             $user = ["name" => "", "student_id" => Auth::user()->id, "gender" => "", "birth" => "", "address" => "", "phone_number" => "", "collage" => "", "collage_type" => "", "github" => "", "intern" => "", "hackathon" => "", "work" => "", "tech" => $tech];
             UserProfile::create($user);
         }
         $data = ['名前' => Auth::user()->name, '性別' => $user['gender'] === "man" ? "男" : "女", '誕生日' => $user['birth'], '住所' => $user['address'], "メールアドレス" => Auth::user()->email, '電話番号' => $user['phone_number'], '大学名' => $user['collage'], '学部' => $user['collage_type'], 'Github' => $user['github']];
         $tech = json_decode($user['tech'], true);
         $award = ['インターン' => $user['intern'], 'ハッカソン' => $user['hackathon'], '仕事' => $user['work']];
         return view('mypage', ["datas" => $data, "color" => $color, "awards" => $award, "tech" => $tech]);
     } else {
         logger("企業アカウントナリ");
         // 企業用ページを表示
         $profile = CompanyProfile::where('company_id', '=', Auth::user()->id)->first();
         logger($profile);
         if ($profile === null) {
             logger("新規作成するナリ");
             $profile = ['name' => "", 'company_id' => Auth::user()->id, 'phone_number' => "", 'email' => "", 'homepage' => ""];
             CompanyProfile::create($profile);
         }
         $works = Post::where('company_id', '=', Auth::user()->id)->get();
         logger($profile);
         return view('mypage_company', ['profile' => $profile, 'works' => $works, 'color' => $color]);
     }
 }
コード例 #13
0
 public function user_posts_draft(Request $request)
 {
     $user = $request->user();
     $posts = Post::where('author_id', $user->id)->where('active', 0)->orderBy('created_at', 'desc')->paginate(5);
     $title = $user->name;
     return view('home')->withPosts($posts)->withTitle($title);
 }
コード例 #14
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     $post = Post::where('slug', $slug)->firstOrFail();
     $moreWorks = Work::orderByRaw('RAND()')->take(3)->get();
     $morePosts = Post::where('slug', '!=', $post->slug)->orderByRaw('RAND()')->take(3)->get();
     return view('posts.show', compact("post", "moreWorks", "morePosts"));
 }
コード例 #15
0
ファイル: BlogController.php プロジェクト: patlegris/ConfPHP
 /**
  * @param $id
  * @param $slug
  * @return the view of the active post
  */
 public function showPost($id, $slug)
 {
     if (!($post = Post::where('slug', $id)->first())) {
         $post = Post::find((int) $id);
     }
     return view('front.blog.single', compact('post'));
 }
コード例 #16
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $categories = Category::all();
     $category = Category::findOrFail($id);
     $posts = Post::where('category_id', $category->id)->orderBy('created_at', 'DESC')->paginate(4);
     return view('categories.show')->with('categories', $categories)->with('posts', $posts)->with('title', $category->title);
 }
コード例 #17
0
 public function hot()
 {
     $postType = '熱門文章';
     $posts = \App\Post::where('page_view', '>=', 100)->orderBy('page_view', 'desc')->orderBy('created_at', 'desc')->paginate(5);
     $data = compact('postType', 'posts');
     return view('posts.index', $data);
 }
コード例 #18
0
ファイル: PostsController.php プロジェクト: Ekbert/crud_local
 public function hot()
 {
     $posts = \App\Post::where('page_view', '>', '100')->orderBy('id', 'desc')->paginate(5);
     /* 略 */
     $data = compact('posts');
     return view('posts.index', $data);
 }
コード例 #19
0
ファイル: SubdootController.php プロジェクト: nehero/updoot
 public function getSubdoot($subdoot)
 {
     $sub = Subdoot::whereName($subdoot)->firstOrFail();
     $filter = 'hot';
     $posts = Post::where('subdoot_id', '=', $sub->id)->latest()->get();
     return view('subdoot.show', compact('sub', 'filter', 'posts'));
 }
コード例 #20
0
ファイル: Front.php プロジェクト: GanjaGanja/larashop
 public function blog()
 {
     $posts = Post::where('id', '>', 0)->paginate(3);
     $posts->setPath('blog');
     $data['posts'] = $posts;
     return view('blog', array('data' => $data, 'title' => 'Latest Blog Posts', 'description' => '', 'page' => 'blog', 'brands' => $this->brands, 'categories' => $this->categories, 'products' => $this->products));
 }
コード例 #21
0
ファイル: HomeController.php プロジェクト: Ruiming/blog
 /**
  * admin主页显示
  *
  */
 public function index()
 {
     $posts = Post::where('is_draft', '==', 0)->orderBy('updated_at', 'desc')->take(5)->get();
     $times = array();
     foreach ($posts as $key => $post) {
         $timediff = time() - strtotime($post->updated_at);
         $days = intval($timediff / 86400);
         $remain = $timediff % 86400;
         $hours = intval($remain / 3600);
         $remain = $remain % 3600;
         $mins = intval($remain / 60);
         if ($days > 0) {
             $times[$key] = $days . "天前";
         } else {
             if ($days == 0 && $hours > 0) {
                 $times[$key] = $hours . "小时前";
             } else {
                 if ($hours == 0 && $mins > 0) {
                     $times[$key] = $mins . "分钟前";
                 } else {
                     if ($mins <= 0) {
                         $times[$key] = "1分钟前";
                     }
                 }
             }
         }
         $post->content = EndaEditor::MarkDecode($post->content);
     }
     return view('home')->withPosts($posts)->withTimes($times);
 }
コード例 #22
0
 /**
  * Returns a thread and its replies to the client. 
  *
  * @var Board $board
  * @var integer|null $thread
  * @return Response
  */
 public function getThread(Request $request, Board $board, $thread)
 {
     if (is_null($thread)) {
         return abort(404);
     }
     $input = $request->only('updatesOnly', 'updateHtml', 'updatedSince');
     if (isset($input['updatesOnly'])) {
         $updatedSince = Carbon::createFromTimestamp($request->input('updatedSince', 0));
         $posts = Post::where('posts.board_uri', $board->board_uri)->withEverything()->where(function ($query) use($thread) {
             $query->where('posts.reply_to_board_id', $thread);
             $query->orWhere('posts.board_id', $thread);
         })->where(function ($query) use($updatedSince) {
             $query->where('posts.updated_at', '>=', $updatedSince);
             $query->orWhere('posts.deleted_at', '>=', $updatedSince);
         })->withTrashed()->orderBy('posts.created_at', 'asc')->get();
         if (isset($input['updateHtml'])) {
             foreach ($posts as $post) {
                 $appends = $post->getAppends();
                 $appends[] = "html";
                 $post->setAppends($appends);
             }
         }
         return $posts;
     } else {
         // Pull the thread.
         $thread = $board->getThreadByBoardId($thread);
         if (!$thread) {
             return abort(404);
         }
     }
     return $thread;
 }
コード例 #23
0
ファイル: BlogController.php プロジェクト: Ruiming/blog
 /**
  * 博客首页
  *
  */
 public function main()
 {
     $posts = Post::where('is_draft', '==', 0)->orderBy('created_at', 'desc')->paginate(config('blog.posts_per_page'));
     foreach ($posts as $post) {
         $post->content = EndaEditor::MarkDecode($post->content);
     }
     return view('blog.index', compact('posts'));
 }
コード例 #24
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CommentRequest $request, $title, $slug)
 {
     $comment = new Comment($request->all());
     $comment->user_id = Auth::user()->id;
     $comment->post_id = Post::where('slug', '=', $slug)->first()->id;
     Auth::user()->posts()->save($comment);
     return redirect("/hub/{$title}/{$slug}");
 }
コード例 #25
0
 public function search(Request $request)
 {
     //关键字处理
     $kw = $this->format($request->input('keyword'));
     //
     $posts = Post::where('title', 'like', '%' . $kw . '%')->get();
     return view('search.search', compact('posts', 'kw'));
 }
コード例 #26
0
 public function getBlog()
 {
     $user = \Auth::user();
     $userId = $user->id;
     $userName = $user->name;
     $posts = \App\Post::where('user_id', '=', $userId)->orderBy('date', 'DESC')->get();
     return view('blog.view-blog')->with('posts', $posts)->with('userName', $userName);
 }
コード例 #27
0
 public function search(Post $post, Subreddit $subreddit, Request $request)
 {
     $query = $request->input('search');
     $subreddit = Subreddit::with('posts.votes')->with('moderators.user')->first();
     $posts = Post::where('title', 'LIKE', '%' . $query . '%')->get();
     $isModerator = false;
     return view('site.search', compact('query', 'subreddit', 'posts', 'isModerator'));
 }
コード例 #28
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Request::get('filter')) {
         $records = Post::where('title', 'LIKE', '%' . Request::get('filter') . '%')->paginate(10);
     } else {
         $records = Post::paginate(10);
     }
     return view('back::scope.blog.posts.index', compact('records'));
 }
コード例 #29
0
 public function index()
 {
     if (Input::has('group_id')) {
         $posts = Post::where('group_id', Input::get('group_id'))->paginate(10)->toArray();
     } else {
         $posts = Post::orderBy('id', 'desc')->paginate(10)->toArray();
     }
     return view('admin.posts.index', compact('posts'));
 }
コード例 #30
0
ファイル: PostRepository.php プロジェクト: ncnlinh/scribl
 public function findByTag($tag)
 {
     $posts = Post::where('tag', '=', $tag)->get();
     if (count($posts->toArray()) == 1) {
         return Post::where('tag', '=', $tag)->get()[0];
     } else {
         return null;
     }
 }