public function random() { $model = new \App\Model\Post(); $begin = rand($model->min('id'), $model->max('id') - 25); $posts = $model->where('id', '>', $begin)->paginate(25); return view('post/list')->with('posts', $posts)->with('type', ['name' => 'random', 'title' => "随机"]); }
public function getDetail(Request $request) { $id = $request->route('id'); $post = PostModel::where('pos_id', $id)->first(); $menus = $this->getMenu(); return view('front.detail', compact('post', 'menus')); }
public function indexAction() { $data['title'] = 'Blog Tin Tức'; $data['menu'] = Menu::where('status', 1)->get(); $data['post'] = Post::where('status', 1)->get(); return $this->render('default/home/index.html.twig', $data); }
public function showHome() { //gets latest post $news = Post::where('is_published', 1)->where('is_active', 1)->where('post_type', 1)->orderBy('updated_at', 'desc')->first(); $job = Post::where('is_published', 1)->where('is_active', 1)->where('post_type', 2)->orderBy('updated_at', 'desc')->first(); $product = Product::where('is_active', 1)->orderby('updated_at', 'desc')->first(); $project = Project::where('is_public', 1)->where('is_active', 1)->orderBy('updated_at', 'desc')->first(); $newsContent = htmlspecialchars_decode($news->content, ENT_NOQUOTES); $news->content = $newsContent; //dd($news); return view('pages.home', ['news' => $news, 'job' => $job, 'product' => $product, 'project' => $project]); }
/** * Execute the console command. * * @return mixed */ public function fire() { $post = \App\Model\Post::where('to_local', '=', '0')->update(['to_local' => '1']); $this->info($post->id); die; \App\Model\Post::where('id', '>=', \App\Model\SiteConfig::get('post_image_to_local'))->chunk(200, function ($posts) { foreach ($posts as $post) { $this->postImageToLocal($post); $this->info($post->id); \App\Model\SiteConfig::set('post_image_to_local', $post->id); } }); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { try { $this->validate($request, ['title' => 'required|max:255|min:3', 'content' => 'required|min:10']); $ispublished = $request->input('is_published') ? true : false; $isactive = $request->input('is_active') ? true : false; $content = htmlspecialchars($request->input('content'), ENT_NOQUOTES); $postobj = new Post(); $postobj->where('id', $id)->update(['title' => $request->input('title'), 'content' => $request->input('content'), 'post_type' => $request->input('post_type'), 'is_published' => $ispublished, 'is_active' => $isactive]); //update attachment images if ($request->has('img')) { foreach ($request->input('img') as $img) { //unserialize image value $imgVal = unserialize($img); if ($imgVal[1]) { $fileObj = new Files(); $fileObj->where('id', $imgVal[0])->update(['attachment_id' => $id]); } else { $fileObj = new Files(); $fileObj->where('id', $imgVal[0])->update(['is_active' => false]); } } } return Redirect::to("/back/post/edit/{$id}")->with('message', $request->input('title') . ' was successfully updated'); } catch (Exception $e) { return Redirect::to("/back/post/edit/{$id}")->with('message', 'Oops! Something went wrong. Please try again later'); } }
public function index() { $posts = PostModel::where("pos_status_cd", "ACT")->get(); return view('posts.index', compact('posts')); }
public function index() { $posts = Post::where("pos_status_cd", "ACT")->get(["pos_id", "pos_name", "pos_image", "pos_sum"]); $menus = $this->getMenu(); return view('home', compact('posts', 'menus')); }
/** * ユーザ削除 */ public function postDelete(Request $request) { if ($request->id == Auth::user()->id) { return redirect()->back()->withErrors(['現在ログイン中なので削除できません。']); } $user = User::findOrFail($request->id); DB::transaction(function () use($user) { $user->delete(); Category::where('user_id', $user->id)->delete(); Post::where('user_id', $user->id)->delete(); }); $user->delete(); \Session::flash('flash_message', '削除しました。'); return redirect('/users'); }
public function getPost_skip_take($category, $skip, $take) { return Post::where('cateID', $category)->orderBy('id', 'desc')->skip($skip)->take($take)->get(); }
/** * カテゴリー削除 */ public function postDelete(Request $request) { $category = Category::findOrFail($request->id); DB::transaction(function () use($category) { $category->delete(); Post::where('category_id', $category->id)->delete(); }); $category->delete(); \Session::flash('flash_message', '削除しました。'); return redirect('/categories'); }