本文整理汇总了PHP中app\Post::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::update方法的具体用法?PHP Post::update怎么用?PHP Post::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeStatus
public function changeStatus(Post $post)
{
if ($post->status == 1) {
$post->update(['status' => 0]);
Flash::success(trans('admin/messages.postBan'));
} elseif ($post->status == 0) {
$post->update(['status' => 1]);
Flash::success(trans('admin/messages.postActivate'));
}
return redirect()->back();
}
示例2: 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');
}
示例3: save
public function save(Post $post, Request $req)
{
if ($req->isMethod('post')) {
$fields = [];
foreach ($req->all() as $k => $v) {
$fields[$k] = $v;
}
unset($fields['_token']);
$post->update($fields);
return view('post.post', ['posts' => Post::all()]);
}
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param Requests\Post $request
* @param Post $post
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update(Requests\Post $request, Post $post)
{
$category = Category::find($request->get('category_id'));
$post->update($request->all());
if (!$request->has('slug')) {
$post->slug = Str::slug($request->get('name'));
}
$category->posts()->save($post);
return redirect('backend/posts');
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Post $post
* @return Response
*/
public function update(Post $post, PostRequest $request)
{
$post->update($request->all());
$post->tags()->sync($request->input('tag_list', []));
$post->slug = str_slug($post->title, "-");
$post->save();
return redirect('posts/postsAuth');
}
示例6: vote
private function vote(Post $post, $vote)
{
if ($vote == 1) {
$voteCount = $post->getAttributeValue('vote_count') + 1;
} else {
$voteCount = $post->getAttributeValue('vote_count') - 1;
}
$post->update(['vote_count' => $voteCount]);
Auth::user()->post_vote()->create(['up' => $vote, 'post_id' => $post->getAttributeValue('id')]);
return view('posts.show', compact('post'));
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param Requests\PostRequest $request
* @param Post $post
* @return \Response
*/
public function update(Requests\PostRequest $request, $post)
{
$post->update($request->input());
return redirect()->back()->with('success', trans('post.updated'));
}
示例8: update
/**
* Update your post.
*
* @param Post $posts
* @param PostRequest $request
* @return Response
*/
public function update(Post $posts, PostRequest $request)
{
$posts->update($request->all());
return redirect('posts');
}
示例9: update
public function update(PostRequest $request, Post $post)
{
$post->update($request->except(['_token']));
$this->syncTags($post, $request->input('tag_list'));
return redirect('dash/post')->with('message', 'Post was update success.');
}
示例10: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update(Post $post, PostRequest $request)
{
$post->update($request->all());
$post->tags()->sync($request->input('tags'));
\Session::flash('flash_message_updated', 'Tu post ha sido actualizado');
return redirect('posts');
}
示例11: apiUpdatePost
/**
* API for updating a post
*/
public function apiUpdatePost(PostRequest $request, Post $post)
{
$post->update($request->all());
return $post;
}
示例12: update
/**
* Update the specified resource in storage.
*
* @param \App\Post $Post
* @param \Illuminate\Http\Request $request
* @return Response
*/
public function update(Post $post, Request $request)
{
$this->validate($request, $this->rules);
$input = array_except(Input::all(), '_method');
$post->update($input);
return Redirect::route('superadmin.posts.index', $post->slug)->with('message', 'Post updated.');
// show after update post
//return view('posts.show', compact('post'));
}
示例13: update
/**
* Update the specified resource in storage.
*
* @param PostRequest $request
* @return Response
* @internal param int $id
*/
public function update(Post $post, PostRequest $request)
{
$post->update($request->all());
return redirect('posts')->with('flash_message', 'Post updated!');
}
示例14: postGroupDelete
public function postGroupDelete(Request $request, Post $post, Comment $comment)
{
if ($request->user()->cannot('delete-problem-comment', [$post, $comment])) {
return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 1, 'msg' => 'شما مجوز حذف این پست را ندارید.', 'msgType' => 'danger', 'returns' => ['num_comments' => '']];
}
$comment->delete();
$num_comments = $post->comments()->count();
$post->update(['num_comment' => $num_comments]);
return ['hasCallback' => 1, 'callback' => 'post_comment_delete', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['num_comments' => $num_comments]];
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param PostRequest $request
* @param User $user
* @param Post $post
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update(PostRequest $request, User $user, Post $post)
{
$post->update($request->all());
// Using Input instead of Request due to an error when no tags selected
$this->sync_tags($post, \Input::get('tag_list'));
return redirect('users/' . $user->profile_link . '/posts');
}