コード例 #1
0
ファイル: PostsController.php プロジェクト: shawon922/blog
 public function show($id)
 {
     $post = Post::findOrFail($id);
     //dd($post->created_at->diffForHumans());
     //dd($post->published_at);
     return view('posts.show', compact('post'));
 }
コード例 #2
0
ファイル: PostController.php プロジェクト: kohrVid/L5Beauty
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $post = Post::findOrFail($id);
     $post->tags()->detach();
     $post->delete();
     return redirect()->routes("admin.post.index")->withSuccess("Post deleted.");
 }
コード例 #3
0
ファイル: PostController.php プロジェクト: andyzulu/mini-cms
 public function update(Request $request, $slug)
 {
     $this->validate($request, ['title' => 'required | unique:posts,title,' . $request->id, 'slug' => 'required | unique:posts,slug,' . $request->id, 'content' => 'required']);
     $post = Post::findOrFail($request->id);
     $post->update(['title' => $request->get('title'), 'content' => $request->get('content'), 'description' => $request->get('description'), 'slug' => $request->get('slug')]);
     return redirect('admin/posts');
 }
コード例 #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function update($id, Request $request)
 {
     $post = Post::findOrFail($id);
     $post->update($request->all());
     Session::flash('flash_message', 'Post updated!');
     return redirect('post');
 }
コード例 #5
0
ファイル: PostController.php プロジェクト: arthurolg/blog
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $post = Post::findOrFail($id);
     $post->tags()->detach();
     $post->delete();
     return redirect()->route('admin.post.index')->withSuccess('Artículo borrado.');
 }
コード例 #6
0
 /**
  * Show form to update post with right data
  *
  * @param PostRequest|Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(PostRequest $request, $id)
 {
     $post = Post::findOrFail($id);
     $post->update($request->all());
     flash('Post modified with success');
     return redirect()->route('admin-posts.index');
 }
コード例 #7
0
ファイル: PostsController.php プロジェクト: nickdunn2/breddit
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $post = Post::findOrFail($id);
     $this->authorize('update-destroy', $post);
     $post->delete();
     return $post;
 }
コード例 #8
0
ファイル: PostRequest.php プロジェクト: spitzgoby/spitzgoby
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     if ($this->isUpdate()) {
         return Post::findOrFail($this->get('id'))->user_id == \Auth::id();
     }
     return \Auth::check();
 }
コード例 #9
0
 public function show($id)
 {
     $post = Post::findOrFail($id);
     // $user = Auth::user()->name;
     // $usr = Auth::user();
     return view('posts.show', compact('post'));
 }
コード例 #10
0
 /**
  * Test Post -> Dificulty Level relationship
  *
  * @return void
  */
 public function testPostDificultyLevelRelationship()
 {
     $this->assertTrue(Post::findOrFail(1) instanceof Post);
     $relationshipCollection = Post::find(1)->dificulty()->get();
     $collection = collect([]);
     $this->assertTrue($relationshipCollection instanceof $collection);
 }
コード例 #11
0
 public function destroy(DeletePostRequest $request, $id)
 {
     $post = Post::findOrFail($id);
     $profile_path = profile_path($post->profile);
     $post->delete();
     return redirect()->to($profile_path);
 }
コード例 #12
0
 /**
  * Update the given post.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $post = Post::findOrFail($id);
     if (Gate::denies('update', $post)) {
         abort(403);
     }
 }
コード例 #13
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $post = Post::findOrFail($id);
     $post->update($request->all());
     $tags = $request->input('tag_list') ? $request->input('tag_list') : [];
     $post->tags()->sync($this->syncUpTags($tags));
     return redirect('/blog');
 }
コード例 #14
0
ファイル: PostController.php プロジェクト: rogercbe/acl_roles
 public function edit($id)
 {
     $post = Post::findOrFail($id);
     if (Gate::denies('edit_forum') or !$this->user->owns($post)) {
         abort(403, 'Sorry not sorry');
     }
     return view('posts.edit', compact('post'));
 }
コード例 #15
0
ファイル: PostsController.php プロジェクト: MartinRowe/blog
 public function handleDelete()
 {
     // Handle the delete confirmation.
     $id = \Input::get('post');
     $post = Post::findOrFail($id);
     $post->delete();
     return \Redirect::action('PostsController@index');
 }
コード例 #16
0
ファイル: BlogController.php プロジェクト: celine24/Back
 /**
  * @param $id
  * @return \Illuminate\View\View
  */
 public function article($id)
 {
     $post = Post::findOrFail($id);
     $userPosts = Post::published()->orderByRaw('RAND()')->where('user_id', $post->user->id)->where('id', '!=', $post->id)->orderBy('created_at', 'desc')->take(3)->get();
     $jobPosts = Post::published()->orderByRaw('RAND()')->where('job_id', $post->job->id)->where('id', '!=', $post->id)->get()->take(2);
     $postSticky = Post::published()->orderByRaw('RAND()')->where('is_sticky', 'on')->where('id', '!=', $post->id)->take(1)->get();
     return view('pages.blog.article', compact('post', 'userPosts', 'jobPosts', 'postSticky'));
 }
コード例 #17
0
 public function editPost($id, EditPostRequest $request)
 {
     $post = Post::findOrFail($id);
     $post->update(['post' => $request->input('post'), 'editor_id' => \Auth::id(), 'editor_name' => \Auth::user()->name, 'was_edited' => 1, 'edit_reason' => $request->input('edit_reason')]);
     Notification::create(['not_title' => 'Kliknij i przejdź do posta, aby sprawdzić szczegóły', 'not_body' => 'Twój post w artykule został edytowany', 'not_status' => 5, 'not_from_user_name' => \Auth::user()->name, 'user_id' => $post->user['id'], 'not_route' => '' . $request->input('take_uri') . '#post' . $id . '']);
     flash()->success('Udało Ci się edytować post o ID <b>' . $id . '</b>!');
     return redirect('/admin/article/' . $request->input('take_article_id') . '');
 }
コード例 #18
0
 public function show($id)
 {
     $post = Post::findOrFail($id);
     if (Gate::denies('show-post', $post)) {
         abort(403, 'Sorry, denied');
     }
     return $post->title;
 }
コード例 #19
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $post = Post::findOrFail($id);
     $articles = Post::published()->get();
     $user = Auth::user();
     $post->load('user', 'comments');
     return view('posts.post', compact('post', 'articles', 'user'));
 }
コード例 #20
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $post = Post::findOrFail($id);
     if (Gate::denies('update', $post)) {
         abort(403, 'no f*****g way bitch');
     }
     return $post->title;
 }
コード例 #21
0
ファイル: PostsController.php プロジェクト: e-noumene/Back
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $post = Post::findOrFail($id);
     if ($request->has('publication')) {
         $post->published = $request->get('publication');
         $post->save();
     }
     return redirect(route('admin.posts.index'));
 }
コード例 #22
0
 public function show($id)
 {
     $post = Post::findOrFail($id);
     // dd(Gate::denies('edit_post', $post));
     if (Gate::denies('edit_post', $post)) {
         return 'Khong duoc roi ban oi';
     }
     return $post->title;
 }
コード例 #23
0
 public function edit($id)
 {
     $post = Post::findOrFail($id);
     if (Gate::denies('update', $post)) {
         Alert::danger('No tienes permisos para editar este post');
         return redirect('posts');
     }
     return $post->title;
 }
コード例 #24
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $post = Post::findOrFail($id);
         echo $post;
     } catch (ModelNotFoundException $e) {
         return Response::json(['error' => 'The specified resource does not exist.'], HttpResponse::HTTP_NOT_FOUND);
     }
 }
コード例 #25
0
ファイル: PostFormFields.php プロジェクト: visor86/blogs
 protected function fieldsFromModel($id, array $fields)
 {
     $post = Post::findOrFail($id);
     $fieldNames = array_keys($fields);
     $fields = ['id' => $id];
     foreach ($fieldNames as $field) {
         $fields[$field] = $post->{$field};
     }
     return $fields;
 }
コード例 #26
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $this->data['post'] = App\Post::findOrFail($id);
     $this->data['thread'] = App\Thread::findOrFail($this->data['post']->thread_id);
     if (!\Auth::hasPerm($this->data['post']->user_id)) {
         \Session::flash('flash_message', 'You do not have permission to edit this post.');
         return redirect('thread/' . $this->data['post']->thread_id);
     }
     return view('forum.posts.edit', $this->data);
 }
コード例 #27
0
 /**
  * Return the field values from the model
  * @param  integer $id     Post ID
  * @param  array  $fields postModelFieldList
  * @return array         $fieldsList
  */
 public function fieldsFromModel($id, array $fields)
 {
     $post = Post::findOrFail($id);
     $fieldNames = array_keys(array_except($fields, ['tags']));
     $fields = ['id' => $id];
     foreach ($fieldNames as $field) {
         $fields[$field] = $post->{$field};
     }
     $fields['tags'] = $post->tags()->pluck('tag')->all();
     return $fields;
 }
コード例 #28
0
 public function destroy($postId)
 {
     try {
         $post = Post::findOrFail($postId);
         $post->delete();
     } catch (Exception $e) {
         Session::flash('message', 'Fail : ' . $e->getMessage());
         return Redirect::back();
     }
     return Redirect::to(route('admin.post.index'));
 }
コード例 #29
0
ファイル: PostFormFields.php プロジェクト: kohrVid/L5Beauty
 protected function fieldsFromModel($id, array $fields)
 {
     $post = Post::findOrFail($id);
     $fieldNames = array_keys(array_except($fields, ["tags"]));
     $fields = ["id" => $id];
     foreach ($fieldNames as $field) {
         $fields[$field] = $post->{$field};
     }
     $fields["tags"] = $post->tags()->lists("tag")->all();
     return $fields;
 }
コード例 #30
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         $id = $request->route()->getParameter('posts');
         $post = \App\Post::findOrFail($id);
         $user = $this->auth->user();
         if ($post->user_id != $user->id) {
             return redirect()->route('posts.index')->with('status', 'No Access.');
         }
     }
     return $next($request);
 }