/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(PostRequest $request) { $Article = Auth::user()->posts()->create($request->all()); $Article->tags()->attach($request->input('tag_list')); Session::flash('success', 'El articulo se creo correctamente!'); return back(); }
public function Ostore($id, PostRequest $request) { $post = new Post($request->all()); $organization = Organization::findOrFail($id); $organization->posts()->save($post); return redirect('/home/posts'); }
public function update(PostRequest $request, $id) { $this->post->find($id)->update($request->all()); $post = $this->post->find($id); $post->tags()->sync($this->getTagsIds($request->tags)); return redirect()->route('admin.posts.index'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(PostRequest $request, $id) { //dd($request->except('_token','_method')); $post = Post::find($id); $post->update($request->except('_token')); return redirect()->route('posts.show', $post); }
public function update(PostRequest $request, $id) { $post = \App\Post::findOrFail($id); $post->update($request->all()); $post->tags()->sync($request->input('tag_list')); return redirect('admin/post'); }
public function store(PostRequest $request) { if (Input::has('link')) { $input['link'] = Input::get('link'); $info = Embed::create($input['link']); if ($info->image == null) { $embed_data = ['text' => $info->description]; } else { if ($info->description == null) { $embed_data = ['text' => '']; } else { $orig = pathinfo($info->image, PATHINFO_EXTENSION); $qmark = str_contains($orig, '?'); if ($qmark == false) { $extension = $orig; } else { $extension = substr($orig, 0, strpos($orig, '?')); } $newName = public_path() . '/images/' . str_random(8) . ".{$extension}"; if (File::exists($newName)) { $imageToken = substr(sha1(mt_rand()), 0, 5); $newName = public_path() . '/images/' . str_random(8) . '-' . $imageToken . ".{$extension}"; } $image = Image::make($info->image)->fit(70, 70)->save($newName); $embed_data = ['text' => $info->description, 'image' => basename($newName)]; } } Auth::user()->posts()->create(array_merge($request->all(), $embed_data)); return redirect('/subreddit'); } Auth::user()->posts()->create($request->all()); return redirect('/subreddit'); }
public function atualizar($id, PostRequest $request) { $tags_ids = $this->tagIDs($request->tags); $this->post->find($id)->update($request->all()); $post = $this->post->find($id); $post->tags()->sync($tags_ids); return redirect()->route('admin.posts.index'); }
/** * Store new post * * @param PostRequest $request * @return \Illuminate\Http\Response */ public function store(PostRequest $request) { $post = new Post($request->all()); $post['published_at'] = Carbon::now(new DateTimeZone(config('app.timezone'))); $this->user->profile->posts()->save($post); flash()->success('Success', 'Your post has been created!'); return redirect()->route('profiles.show', ['profiles' => $this->user->profile->id]); }
/** * Store new post. * * @return \Illuminate\Http\Response */ public function store(PostRequest $request) { $newpost = $this->postService->create($request->all()); if (!$newpost) { return redirect('/')->withErrors(); } $data = ['post' => $newpost]; return view('posts.post', $data)->render(); }
/** * PUT admin/posts/{post} * * @param Post $post * @param PostRequest $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function update(Post $post, PostRequest $request) { $post->update($request->all()); if ($request->has('tag_list')) { $post->tags()->sync(Tag::findOrCreateMany($request->get('tag_list'))); } flash()->success('The post has been updated'); return redirect('/admin/posts'); }
public function store(PostRequest $request, TagRepository $tagRepository) { $inputs = array_merge($request->all(), ['user_id' => $request->user()->id]); $post = $this->postRepository->store($inputs); if (isset($inputs['tags'])) { $tagRepository->store($post, $inputs['tags']); } return redirect(route('post.index')); }
/** * Guarda la nueva publicación * * @param PostRequest $request -> valida los campos requeridos para crear una publicación * @return \Illuminate\Http\Response */ public function store(PostRequest $request) { /* crea un nuevo objeto TestPostm con la información que se ingresó en la forma */ /* $request->all(), trae la información que se ingreso la forma */ $newPost = new TestPost($request->all()); /* especifica a que usuario le pertenece el nuevo posts y lo guarda en la tabla testposts */ Auth::user()->posts()->save($newPost); /* redirige al listado de publicaciones realizados por el usuario loggueado */ return redirect('posts'); }
public function update(PostRequest $request, Post $post) { if ($post->user()->getResults() != Auth::user()) { return response('Unauthorized.', 401); } $post->update($request->all()); $post->tags()->detach(); $post->tags()->attach($request->input('tags')); return view('posts.show', compact('post')); }
public function update(PostRequest $request, $id) { $post = $this->post->find($id); if ($post) { $post->update($request->all()); return redirect()->route('admin.posts.edit', ['id' => $post->id]); //return redirect('admin/posts/edit/'.$post->id); } else { } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(PostRequest $request) { $post = new Post(); $topic_id = $request->input('topic_id'); $post->content = $request->input('content'); $post->user_id = $request->user()->id; $post->topic_id = $topic_id; $post->save(); return Redirect::action('TopicController@show', array('id' => $topic_id)); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request\PostRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(PostRequest $request, Post $post) { $this->authorize('update', $post); $post->title = $request->get('title'); $post->text = $request->get('text'); $post->abstract = $post->getAbstract($request->get('text')); $post->user_id = Auth::user()->id; $post->save(); Flash::success('Post successfully updated'); return redirect('posts'); }
public function store(PostRequest $request) { $post = \App\Post::create($request->all()); $data = compact('post'); //v1,ok //return redirect()->route('posts.create'); //v2,ok return redirect()->route('posts.show', $data); //old //return redirect()->route('posts.show', $post->id); }
/** * Guarda la nueva publicación * * @param PostRequest $request -> valida los campos requeridos para crear una publicación * @return \Illuminate\Http\Response */ public function store(PostRequest $request) { /* crea un nuevo objeto TestPostm con la información que se ingresó en la forma */ /* $request->all(), trae la información que se ingreso la forma */ $newPost = new TestPost($request->all()); /* especifica a que usuario le pertenece el nuevo posts y lo guarda en la tabla testposts */ Auth::user()->posts()->save($newPost); /* Feedback para el usuario, que su publicación será procesada para ver si el contenido es apropiado */ Session::flash('flash_message', 'Tu publicación está siendo procesada, para ver si el contenido es apropiado'); /* redirige al listado de publicaciones realizados por el usuario loggueado */ return redirect('posts'); }
/** * Store a newly created resource in storage. * * @param PostRequest|Request $request * @return Response */ public function store(PostRequest $request) { if (Input::has('link')) { $input['link'] = Input::get('link'); $info = Embed::create($input['link']); $image = \Image::make($info->image)->resize(120, 120)->save('C:\\xampp\\htdocs\\laravel-5\\public\\images' . '/' . str_random(8) . '.jpg'); $embed_data = ['text' => $info->description, 'image' => $image->filename . '.jpg']; //Auth::user()->posts()->create(array_add($request->all(), 'image', $info->image)); Auth::user()->posts()->create(array_merge($request->all(), $embed_data)); return redirect('/articles'); } Auth::user()->posts()->create($request->all()); return redirect('/'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(PostRequest $request, $id) { $post = Post::findOrNew($id); $post->update($request->all()); if ($request->hasFile('link_thumbnail')) { $file = $request->file('link_thumbnail'); $ext = $file->getClientOriginalExtension(); $fileName = str_random(12) . '.' . $ext; $file->move('assets/img/confs', $fileName); $post->link_thumbnail = $fileName; $post->save(); } return redirect('/dashboard'); }
/** * Store a newly created resource in storage. * * @param $categoryId * @param PostRequest $request * @return Response */ public function store($categoryId, PostRequest $request) { if (!Sentinel::getUser()->hasAccess(['threads.create'])) { abort(401); } $category = Category::findOrFail($categoryId); $thread = new Thread(); $thread->category_id = $category->id; $thread->save(); $post = new Post($request->all()); $post->user_id = Sentinel::getUser()->id; $post->thread_id = $thread->id; $post->save(); return redirect()->route('categories.threads.posts.index', [$category->id, $thread->id]); }
/** * @param PostRequest $request * @param $id * @return \Illuminate\Http\RedirectResponse */ public function update(PostRequest $request, $id) { $post = Post::findOrFail($id); $post->name = $request->get("name"); $post->content = $request->get("content"); $post->save(); $this->sync($post, $request->input("tags")); return redirect()->route("posts.index")->with("message", "The post was updated"); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(PostRequest $request, $id) { $post = Post::findOrFail($id); $post->update($request->all()); if ($request->input('tag_list') != '') { $tags = (array) $request->input('tag_list'); $this->syncTags($post, $tags); } flash('Post has been updated'); return 1; }
public function store(PostRequest $request, PhotoGestion $photoGestion) { if ($photoGestion->save($request->file('photo'))) { $input = $request->all(); $input['photo'] = $photoGestion->getPictureLink(); $inputs = array_merge($input, ['user_id' => $request->user()->id]); /*return 'Le formulaire est bien rempli avec : nom = '.$inputs['user_id'].' type = '.$inputs['type'].' postPicture = '.$inputs['photo'].' photo = '.$photoGestion->getPictureLink().' etat = '.$inputs['etat']; */ $posts = $this->postRepository->store($inputs); //$posts['photo'] = $photoGestion->getPictureLink(); return redirect(route('post.index')); } //$inputs = array_merge($request->all(), ['user_id' => $request->user()->id]); //$this->postRepository->store($inputs); //return redirect(route('post.index')); }
/** * Update the Post * * @param Request $request * @param int $id */ public function update(PostRequest $request, $id) { $post = Post::findOrFail($id); $images = $post->images; $post->fill($request->postFillData(Post::class)); if ($request->hasFile('images')) { // delete file $path = $this->getPath(); if ($images && \File::exists($path . $images)) { \File::delete($path . $images); \File::delete($path . 'thumb/' . $images); } $post->images = $this->uploadImage($request); } else { $post->images = $images; } $post->save(); if ($request->action === 'continue') { return redirect()->back()->withSuccess('Post saved.'); } return redirect()->route('admin.post.index')->withSuccess('Post saved.'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Requests\PostRequest $request) { // Create new banner instance $post = new Post(); // Save banner $post->title = $request->input('title'); $post->slug = $request->input('slug'); $post->content = $request->input('content'); $post->category_id = $request->input('category_id'); $post->status = $request->input('status'); $post->comments = $request->input('comments'); $post->featured = $request->input('featured'); $post->summary = $request->input('summary'); $post->save(); // Set Flash Message session()->flash('flash_message', 'New Post Has Been Created!'); // Redirect to new banner page return redirect('post/'); }
public function store(Requests\PostRequest $request) { $content_url = $request->content_url; $q = Embedly::oembed($request->content_url, ['maxwidth' => '500']); if ($q->error) { return $q->error_message; //Error } else { switch ($q->type) { case 'link': $request['media_url'] = $q->thumbnail_url ? '<img src="' . $q->thumbnail_url . '" height="' . $q->thumbnail_height . '" width="' . $q->thumbnail_width . '" />' : null; break; case 'video': if ($q->html) { $request['media_url'] = $q->html; } elseif ($q->thumbnail_url) { $request['media_url'] = '<img src="' . $q->thumbnail_url . '" height="' . $q->thumbnail_height . '" width="' . $q->thumbnail_width . '" />'; } else { $request['media_url'] = null; } break; case 'photo': $request['media_url'] = $content_url ? '<img src="' . $q->thumbnail_url . '" height="' . $q->thumbnail_height . '" width="' . $q->thumbnail_width . '" />' : null; break; case 'rich': $request['media_url'] = $q->html; break; default: break; } $request['title'] = $q->title ? $q->title : $content_url; $request['type'] = $q->type; } Post::create($request->all()); return redirect(Auth::user()->username); }
public function store(PostRequest $request) { $inputs = array_merge($request->all(), ['user_id' => $request->user()->id]); $this->postRepository->store($inputs); return redirect(route('post.index')); }
/** * Update the specified resource in storage. * * @param PostRequest $request * @param int $id * * @return \Illuminate\Http\RedirectResponse */ public function update(PostRequest $request, $id) { $this->savePost($request->all(), $id); return redirect()->route('admin.posts.index'); }
public function update($id, PostRequest $request) { $this->post->find($id)->update($request->all()); return redirect()->route('admin.posts.index'); }