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'); }
/** * 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('/'); }
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'); }
public function store(PostRequest $request) { // dd($request->all()); $post = Post::create($request->all()); $post->tags()->attach($request->input('tag_list')); return redirect('dash/post')->with('message', 'Post was create success.'); }
public function Ostore($id, PostRequest $request) { $post = new Post($request->all()); $organization = Organization::findOrFail($id); $organization->posts()->save($post); return redirect('/home/posts'); }
/** * 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 update(PostRequest $request, $id) { $post = \App\Post::findOrFail($id); $post->update($request->all()); $post->tags()->sync($request->input('tag_list')); return redirect('admin/post'); }
/** * 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]); }
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'); }
/** * 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'); }
/** * 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(); }
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')); }
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')); }
/** * 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, $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 { } }
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'); }
/** * 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]); }
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')); }
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'); }
/** * Update the specified resource in storage. * * @param App\Http\Requests\PostUpdateRequest $request * @param int $id * @return Response */ public function update(PostRequest $request, $id) { $this->blog_gestion->update($request->all(), $id); return redirect('blog')->with('ok', trans('back/blog.updated')); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(PostRequest $request, $title) { $post = new Post($request->all()); $post->user_id = Auth::user()->id; $post->hub_id = Hub::where('name', '=', $title)->first()->id; $post->slug = preg_replace('/[^A-z0-9-]+/', '-', $post->title); Auth::user()->posts()->save($post); return redirect("/hub/{$title}"); }
/** * Handles the creation of a new thread or reply. * * @param \App\Http\Requests\PostRequest $request * @param Board $board * @param integer|null $thread * @return Response (redirects to the thread view) */ public function putThread(PostRequest $request, Board $board, $thread = null) { // Create the post. $post = new Post($request->all()); $post->submitTo($board, $thread); // Log staff posts. if ($post->capcode_id) { $this->log('log.post.capcode', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "capcode" => $post->capcode->capcode, "role" => $post->capcode->role]); } // Redirect to the new post or thread. if (is_null($thread)) { return redirect("{$board->board_uri}/thread/{$post->board_id}"); } else { return redirect("{$board->board_uri}/thread/{$post->reply_to_board_id}#{$post->board_id}"); } }
/** * Handles the creation of a new thread or reply. * * @param \App\Http\Requests\PostRequest $request * @param Board $board * @param Post|null $thread * @return Response (redirects to the thread view) */ public function putThread(PostRequest $request, Board $board, Post $thread = null) { // Create the post. $post = new Post($request->all()); $post->submitTo($board, $thread); // Log staff posts. if ($post->capcode_id) { $this->log('log.post.capcode', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "capcode" => $post->capcode->getCapcodeName(), "role" => $post->capcode->role]); } $input = $request->only('updatesOnly', 'updateHtml', 'updatedSince'); if ($request->wantsJson()) { $updatedSince = Carbon::createFromTimestamp($request->input('updatedSince', Carbon::now()->subMinutes(4)->timestamp)); $includeHTML = isset($input['updateHtml']); $posts = Post::getUpdates($updatedSince, $board, $thread, $includeHTML); $post->setAppendHTML($includeHTML); $posts->push($post); $posts->sortBy('board_id'); return $posts; } // Redirect to the new post or thread. if ($post->reply_to_board_id) { return redirect("{$board->board_uri}/thread/{$post->reply_to_board_id}#{$post->board_id}"); } else { return redirect("{$board->board_uri}/thread/{$post->board_id}#{$post->board_id}"); } }
/** * @param Post $post */ public function update(Post $post, PostRequest $request) { $post->update($request->all()); }
/** * Update the specified resource in storage. * * @param App\Http\Requests\PostUpdateRequest $request * @param int $id * @return Response */ public function update(PostRequest $request, $id) { $post = $this->blog_gestion->getById($id); $this->authorize('change', $post); $this->blog_gestion->update($request->all(), $post); return redirect('blog')->with('ok', trans('back/blog.updated')); }