/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $allLocations = Marker_location::all(); $allEvents = Events::orderBy('created_at', 'DESC')->get(); $allPost = Posts::orderBy('created_at', 'DESC')->get(); //getting all the post from post database table $allUserPhotos = PhotoMapImageUploader::orderBy('photoMapId')->get(); return view('admin.index', compact('allLocations', 'allEvents', 'allPost', 'allUserPhotos')); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $order = 'DESC'; if ($request->order) { $order = $request->order; } $data = Posts::orderBy('date', $order)->paginate(5); if ($request->ajax()) { return Response::json(View::make('part', array('posts' => $data))->render()); } return View::make('index', array('posts' => $data)); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $allPost = Posts::orderBy('created_at', 'DESC')->get(); //getting all the post from post database table $userInfo = \Auth::user(); $allEvents = Events::orderBy('created_at', 'DESC')->take(2)->get(); $allUserPhotos = PhotoMapImageUploader::orderBy('photoMapId', 'DESC')->take(6)->get(); // $postId = $allPost->id; // $TotalComments = Comments::where('on_post', '5')->count(); // dd($TotalComments); return view('home.index', compact('allPost', 'userInfo', 'allEvents', 'allUserPhotos')); }
/** * Display a listing of the resource. This function is handling root request (localhost:8000) * * @return \Illuminate\Http\Response */ public function index(Request $request) { $posts = Posts::orderBy('created_at', 'desc')->get(); // ako sakame del po del mozhe so paginate() // bidejkji vo baza chuvame samo ime na slika, foreach ($posts as $post) { // slika na post if ($post->post_picture) { $imgName = $post->post_picture; $imgData = base64_encode(File::get('uploads/posts/' . $imgName)); $post->post_picture = $imgData; } // slika na user koj postiral $post->user = $post->author; // tuka smeniv $imgName = $post->user->profile_picture; if ($imgName != "") { $imgData = base64_encode(File::get('uploads/profile_pictures/thumbnails/' . $imgName)); } else { $post->user->profile_picture = base64_encode(File::get('uploads/profile_pictures/profile_picture.png')); } $post->user->profile_picture = $imgData; // komentari $comments = $post->comments; // // zemi gi slikite na korisnicite koi komentirale // foreach ($comments as $comment) { // $comment->user = User::find($comment->user_id); // $imgName = $comment->user->profile_picture; // if($imgName){ // $imgData = base64_encode(File::get('uploads/profile_pictures/' . $imgName)); // } else { // $imgData = base64_encode(File::get('uploads/profile_pictures/profile_picture.png')); // } // $comment->user->profile_picture = $imgData; // } // $post->comments = $comments; // dodaj gi site likes na ovoj post vo response-ot samo kako brojka (poseben servis za koi useri :)) $post->nComments = count($comments); $post->nLikes = count($post->likes); // za sekoj post, vo odnos na toa koj user e avtenticiran t.e. go napravil requestot, pushti mu // flagche dali vekje go lajknal postot ili ne, za da mozhe da se sredi soodvetno vo angular :) if (count(Likes::where('post_id', $post->id)->where('user_id', $request->user()->id)->get()) == 1) { // povekje e greshka $post->liked = true; } else { $post->liked = false; } } return response()->json(['posts' => $posts]); // return view('home')->withPosts($posts)->withUser($user); }
public function viewCourse($courseID) { $course = Courses::find($courseID); if (count($course) < 1) { return view('errors.404'); } if (auth() && auth()->user() && User::find(auth()->user()->getAuthIdentifier())['admin'] >= ConstsAndFuncs::PERM_ADMIN) { $posts = Posts::where('CourseID', '=', $courseID)->orderBy('id', 'asc')->paginate(5); $newpost = Posts::orderBy('id', 'dsc')->take(5)->get()->toArray(); return view('userindex')->with(['Posts' => $posts, 'newpost' => $newpost, 'paginateBaseLink' => '/course/' . $courseID]); } else { if ($course['Hidden'] == 1) { return view('errors.404'); } $posts = Posts::where('CourseID', '=', $courseID)->where('Hidden', '=', 0)->orderBy('id', 'asc')->paginate(5); $newpost = Posts::orderBy('id', 'dsc')->where('Hidden', '=', 0)->take(5)->get()->toArray(); return view('userindex')->with(['Posts' => $posts, 'newpost' => $newpost, 'paginateBaseLink' => '/course/' . $courseID]); } }
public function savePost(Request $request) { if (!AuthController::checkPermission()) { return redirect('/'); } $data = $request->all(); $post = new Posts(); if (array_key_exists('Hidden', $data) && $data['Hidden'] == 'on') { $post->Hidden = 1; } else { $post->Hidden = 0; } $post->CourseID = $data['CourseID']; $post->ThumbnailID = $data['ThumbnailID']; $post->Title = $data['Title']; $post->Description = $data['Description']; $post->NoOfFreeQuestions = $data['NoOfFreeQuestions']; switch ($data['ThumbnailID']) { case '1': // Plain Text $post->save(); $post = Posts::orderBy('id', 'desc')->first(); //Photo $file = $request->file('Photo'); $post->Photo = 'Post_' . $data['CourseID'] . '_' . $post->id . "_-Evangels-English-www.evangelsenglish.com_" . "." . $file->getClientOriginalExtension(); $file->move(base_path() . '/public/images/imagePost/', $post->Photo); $post->update(); break; case '2': // Video $linkVideo = $data['Video']; $post->Video = PostsController::getYoutubeVideoID($linkVideo); $post->save(); break; } $course = Courses::find($post->CourseID); $course->NoOfPosts++; $course->update(); // Save Hashtag $rawHT = $data['Hashtag']; TagsController::tag($rawHT, $post->id); return redirect(route('admin.viewcourse', $post->CourseID)); }
public function viewCourse($courseID) { $posts = Posts::where('CourseID', '=', $courseID)->orderBy('id', 'asc')->paginate(5); $newpost = Posts::orderBy('id', 'dsc')->take(5)->get()->toArray(); return view('userindex')->with(['Posts' => $posts, 'newpost' => $newpost, 'paginateBaseLink' => '/course/' . $courseID]); }
public function show() { $posts = Posts::orderBy('created_at', 'desc')->paginate(3); return view('home')->with('posts', $posts); }
public function blog() { $posts = Posts::orderBy('id', 'desc')->paginate(5); return view('page.blog')->with('posts', $posts); }
public function viewNewestPosts() { // $posts = Posts::take(5)->skip(0)->get()->toArray(); $Posts = Posts::orderBy('id', 'desc')->paginate(5); $newpost = Posts::orderBy('visited', 'dsc')->take(5)->get(); $paginateBaseLink = '/'; // dd($newpost); // dd($Posts); // dd($Posts->toArray()); return view('userindex')->with(compact(['Posts', 'newpost', 'paginateBaseLink'])); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $admin_messages = \App\AdminMessages::where('read', '=', 0); $data = array('active_nav' => $this->active_nav, 'total_users' => \App\User::all()->count(), 'logged_in' => \App\User::where('logged_in', '=', 1)->count(), 'total_categories' => \App\categories::count(), 'total_posts' => \App\Posts::all()->count(), 'latest_users' => \App\User::orderBy('created_at', 'ASC')->limit(10)->get(), 'latest_posts' => \App\Posts::orderBy('created_at', 'ASC')->limit(10)->get(), 'unread_admin_messages' => $admin_messages->count(), 'new_users_month' => \App\User::getFromDate(date('y-m-0'))->count(), 'new_users_week' => \App\User::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_users_day' => \App\User::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'new_posts_month' => \App\Posts::getFromDate(date('y-m-0'))->count(), 'new_posts_week' => \App\Posts::getFromDate(date('y-m-d', strtotime('-7 day')))->count(), 'new_posts_day' => \App\Posts::getFromDate(date('y-m-d', strtotime('-1 day')))->count(), 'admin_messages' => $admin_messages->get()); return view('includes/admin/home')->with($data); }
public function index() { $post = Posts::orderBy('id', 'dsc')->take(3)->get(); return view('mainpage')->with(compact('post')); }