예제 #1
0
 public function store(StoreBlogPostRequest $request)
 {
     $id = $request->input('id');
     $title = $request->input('title');
     $content = $request->input('content');
     $summary = str_summary($content, 100);
     $thumb_img = $request->input('thumb_img');
     $category = $request->input('category');
     $tags = $request->input('tags');
     if ($id) {
         $post = Post::find($id);
     } else {
         $post = new Post();
         $post->author = Auth::user()->id;
     }
     $post->title = $title;
     $post->summary = $summary;
     $post->content = $content;
     $post->thumb_img = $thumb_img;
     $post->save();
     $relations = [];
     $relations[] = ['term_id' => $category];
     if ($tags) {
         foreach ($tags as $tag) {
             $relations[] = ['term_id' => $tag];
         }
     }
     if ($relations) {
         $post->save_relations($relations);
     }
     return redirect()->action('Admin\\PostController@index');
 }
예제 #2
0
 public function show($slug, $id)
 {
     //Tăng view
     $post = Post::find($id);
     $post->views++;
     $post->save();
     $data = ['post' => $this->post->show($id, current_lang())];
     return view('frontend.post', $data);
 }
예제 #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $user = Auth::user();
     $postobj = new Post();
     $post = $postobj->find($id);
     $postTypes = PostType::all();
     $postTypeId = PostType::find($post->post_type);
     $moduleId = 3;
     //post
     //get the image assiociates
     $postFiles = Files::where('attachment_id', $post->id)->where('is_active', True)->where('module_id', $moduleId)->get();
     return view('pages.admin.post.edit', ['post' => $post, 'user' => $user, 'postTypes' => $postTypes, 'moduleId' => $moduleId, 'postFiles' => $postFiles, 'postTypeId' => $postTypeId]);
 }
예제 #4
0
 public function delTagByPost($post_id, $tag_id)
 {
     $post = \App\Model\Post::find($post_id);
     $post->tags()->detach($tag_id);
     return back();
 }
예제 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     Post::find($id)->delete();
     return redirect('post');
 }
예제 #6
0
 public function update(Request $request, $id)
 {
     $input = $request->input();
     $post = Post::find($id)->update($input);
     return redirect()->route('posts.show', $id);
 }
예제 #7
0
 public function getDetail()
 {
     if (!Request::input('id') || Request::input('id') == '') {
         return redirect('admin/Post');
     }
     $id = Request::input('id');
     $data = array();
     $data = Post::find($id);
     $this->page['title'] = 'post';
     return view("layout.admin.Post.detail", $data)->with('page', $this->page);
 }