本文整理汇总了PHP中App\Http\Requests\PostRequest类的典型用法代码示例。如果您正苦于以下问题:PHP PostRequest类的具体用法?PHP PostRequest怎么用?PHP PostRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PostRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* 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();
}
示例2: Ostore
public function Ostore($id, PostRequest $request)
{
$post = new Post($request->all());
$organization = Organization::findOrFail($id);
$organization->posts()->save($post);
return redirect('/home/posts');
}
示例3: update
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');
}
示例4: update
/**
* 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);
}
示例5: update
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');
}
示例6: store
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');
}
示例7: atualizar
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');
}
示例8: store
/**
* 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]);
}
示例9: store
/**
* 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();
}
示例10: update
/**
* 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');
}
示例11: store
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'));
}
示例12: store
/**
* 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');
}
示例13: update
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'));
}
示例14: update
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 {
}
}
示例15: store
/**
* 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));
}