/** * 文章详情. * * @param $id * * @return mixed */ public function detail($id) { $article = $this->postRepository->find($id); $prevId = $id > 1 ? $id - 1 : 1; $nextId = $id > 1 ? $id - 1 : 1; return user_view('docment.detail', compact('article', 'prevId', 'nextId')); }
/** * Loads the profile page * * @param int $userId * @return string */ public function profile($userId) { try { //Get user for who this profile belongs $profileOwner = app('UserRepo')->getUser($userId, 'student'); //Student profile was not found if ($profileOwner == false) { //Show 404 page throw new Exception('Student profile not found', '404'); } //Get Posts $posts = $this->postsRepo->paginateUserPosts($profileOwner); //Get next page url $nextPageUrl = generate_next_page_url($posts); //This is a normal request if (!$this->input->is_ajax_request()) { //Load Student profile $this->load->view('student-profile/timeline', ['title' => $profileOwner->full_name, 'profileOwner' => $profileOwner, 'posts' => $posts, 'nextPageUrl' => $nextPageUrl, 'profileMenu' => 1]); } else { //Return json encoded data echo json_encode(['error' => false, 'grid' => $this->load->view('partials/_posts-grid', ['posts' => $posts], true), 'nextPageUrl' => $nextPageUrl]); } } catch (Exception $e) { //Unexpected error //This is a normal request if (!$this->input->is_ajax_request()) { show_error($e->getMessage(), $e->getCode()); } else { //Return error json echo json_encode(['error' => true, 'message' => $e->getMessage()]); } } }
/** * نمایش داشبورد ادمین * * @param App\Repositories\PostRepository $PostRepository * @param App\Repositories\CommentRepository $CommentRepository * @return Response */ public function Index(PostRepository $PostRepository, CommentRepository $CommentRepository) { $nbrPosts = $PostRepository->getNumber(); $nbrComments = $CommentRepository->getNumber(); $posts = $PostRepository->lists($this->nbrPages); $links = $posts->setPath('')->render(); return view('admin.DashBoard', compact('posts', 'links', 'nbrPosts', 'nbrComments')); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $post = $this->postRepository->find($id); if (!$post) { return $this->respondNotFound(); } return $this->respond(['post' => $this->postTransformer->transform($post)]); }
public function index(Request $request) { if ($request->has("q")) { $es = $this->postRepository->search($request->input("q")); } else { $db = $this->post->fetchAll(); } return view('welcome', compact('db', 'es')); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->scraper = new Scraper(); $this->postRepository = new PostRepository(new Post()); $this->info("Fetching posts from vdm..."); $posts = $this->scraper->scrap(200); $this->info(sprintf("Saving %d posts.", Arrays::size($posts))); Arrays::each($posts, function ($post) { $this->postRepository->create($post->toArray()); }); $this->info("Done."); }
/** * POST: / * * @return redirect(/) */ public function postIndex() { $user = Auth::user(); $message = Input::get('message'); $services = Input::get('services'); foreach ($services as $providerId => $serviceEnabled) { $bIsEnabled = (bool) $serviceEnabled; if ($bIsEnabled === true) { $provider = $this->providerRepository->get($providerId); $post = $this->postRepository->createMessage($provider, $message); $this->dispatch(new PublishMessage($post)); } } return redirect('/'); }
/** * Create a new comment on a post * * @return string */ public function postComment() { try { //Must be an ajax request if (!$this->input->is_ajax_request()) { //Raise error throw new Exception('The request is not allowed', 422); } //User must be logged in if (!$this->auth->check()) { //Raise error throw new Exception('You must be logged in to proceed', 422); } //Set validation $this->form_validation->set_rules('post_id', 'Post Identifier', 'required|xss_clean'); $this->form_validation->set_rules('comment', 'Comment', 'required|xss_clean'); //Apply validation if ($this->form_validation->run() == false) { //Raise error throw new Exception('Missing parameters', '422'); } //Create comment and return echo json_encode(['error' => false, 'commentRow' => $this->load->view('partials/_single-comment-row', ['comment' => $this->commentRepo->createComment($this->postRepo->getPost($this->input->post('post_id')), $this->input->post('comment'), $this->auth->user())], true)]); } catch (Exception $e) { //Unexpected error echo json_encode(['error' => true, 'message' => $e->getMessage()]); } }
/** * تابعی برای نمایش یک پست و کامنتهای مربوطه با آیدی پست * @param int $pst_id * @return view */ public function readPost($pst_id) { $post = $this->PostRepository->get($pst_id); //----> کوئری یوزر عادی $comments = $this->CommentRepository->getApprovedByPostId($pst_id); $newPostsList = $this->PostRepository->newPostsList($this->nbrPages); $mostLikePostsList = $this->PostRepository->mostLikePostsList($this->nbrPages); return view('layout.ReadPost', compact('newPostsList', 'mostLikePostsList', 'pst_id', 'post', 'comments')); }
/** * Get all posts grouped by create date. * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function groupByDate() { $posts = $this->post->all(); $group = []; foreach ($posts as $post) { $date = date_parse($post->created_at); $mYear = $date['year']; $mMonth = $date['month']; // Month or Year not exists current. if (!array_key_exists($mYear, $group)) { $group[$mYear] = []; } if (!array_key_exists($mMonth, $group[$mYear])) { $group[$mYear][$mMonth] = []; } array_push($group[$mYear][$mMonth], $post); } return view('front.archive.date', compact('group')); }
/** * نمایش فرم افزودن پست * * @return Response */ public function addPostForm() { $nbrPosts = $this->PostRepository->getNumber(); $nbrComments = $this->CommentRepository->getNumber(); $nbrTags = $this->PostRepository->getTags(); $url = config('medias.url'); $FormUrl = Route('insertPost'); $FormMethod = "POST"; return view('admin.Post.Form', compact('nbrTags', 'nbrPosts', 'nbrComments', 'FormUrl', 'FormMethod', 'url')); }
/** * Load the Home page or Login/Registration page */ public function index() { //User is logged in if ($this->auth->check()) { //Get the feeds for the user $feeds = $this->postRepo->feeds($this->auth->user()); //Get next page url $nextPageUrl = generate_next_page_url($feeds); //This is a normal request if (!$this->input->is_ajax_request()) { //Load feeds view $this->load->view('pages/feeds', ['title' => 'Uom-Connect', 'feeds' => $feeds, 'nextPageUrl' => $nextPageUrl]); } else { //Return json encoded data echo json_encode(['error' => false, 'grid' => $this->load->view('partials/_posts-grid', ['posts' => $feeds], true), 'nextPageUrl' => $nextPageUrl]); } } else { //Load login/Registration page $this->load->view('auth/login'); } }
/** * @param array $data * @param int|null $id */ protected function savePost(array $data = [], $id = null) { // Image Handling if (isset($data['image'])) { $data['image'] = $this->buildImage($data['slug'], $data['image']); } // We create the Post if ($id === null) { $data['author_id'] = Auth::id(); $this->posts->create($data); } else { $this->posts->update($data, $id); } }
/** * Upload File with Markdown Form. * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function upload(Request $request) { $file = $request->file('upload-file'); $filename = $file->getClientOriginalName(); $filepath = storage_path('app/posts') . '/' . $filename; $file->move(storage_path('app/posts'), $filename); $parsed = parseArticle($filepath); $post = $this->blog->getByColumn($parsed['slug'], 'slug'); if (is_null($post)) { $post = new Post($parsed); $post->published = isset($parsed['publish']); return view('back.blog.create', compact('post')); } else { foreach ($parsed as $key => $value) { $post->{$key} = $value; } $post->published = isset($parsed['publish']); return view('back.blog.edit', compact('post')); } }
/** * Display the specified resource. * * @param string $slug * * @return \Illuminate\View\View */ public function show($slug) { $post = $this->posts->with('tags')->findByField('slug', $slug)->first(); $tags = $this->tags->all(); return view('frontend.pages.blog.show', compact('post', 'tags')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { return $this->postRepository->all(); }
/** * Display a list of the users posts ordered by create date * * @param Request $request * @return Response */ public function index(Request $request, $user) { return view('user.index', ['user' => $this->users->find($user), 'posts' => $this->posts->forUser($user), 'comments' => $this->comments->forUser($user)]); }
/** * Return posts with 'term' in their title * * @param Request $request * @return Response */ public function search(Request $request) { $term = $_GET['q']; return view('posts.index', ['posts' => $this->posts->search($term), 'term' => $term]); }
/** * Display the specified resource. * * @param string $slug * * @return \Illuminate\View\View */ public function show($slug) { $post = $this->posts->findByField('slug', $slug)->first(); return view('frontend.pages.blog.show', compact('post')); }
/** * Display a list of all posts. * * @return \Illuminate\Http\JsonResponse */ public function index() { return view('landing', ['posts' => $this->posts->all(['orderBy' => 'created_at', 'sortOrder' => 'desc'])]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $this->repository->find($id)->delete(); return redirect()->route('admin.post.index'); }
/** * Display a list of all of the user's post. * * @param Request $request * @return Response */ public function index(Request $request) { return view('posts.index', ['posts' => $this->posts->forUser($request->user())]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Category $category, PostRepository $post) { $categories = $category->all(); return view('blog.index', ['categories' => $categories, 'posts' => $post->getAllPublished()]); }
/** * Display posts in category. * * @param ArticleCategory $category * @return \Illuminate\View\View */ public function category(ArticleCategory $category) { $posts = $this->posts->articlesForCategory($category->id, 3); return view('posts.category', compact('category', 'posts')); }
/** * Show the given post. * * @param Request $request * @param string $postId * @return Response */ public function show(Request $request, $postId) { return view('posts.show', ['post' => $this->posts->postInfo($postId)]); }
/** * افزودن پست جدید * * @param App\Http\Requests\PostRequest $request * @return Response */ public function insert(PostRequest $request) { $this->PostRepository->insert($request->all()); return response()->json(); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $post = $this->repository->find($id); return view('posts/post', compact('post')); }