本文整理匯總了PHP中app\Comment::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Comment::delete方法的具體用法?PHP Comment::delete怎麽用?PHP Comment::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Comment
的用法示例。
在下文中一共展示了Comment::delete方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: destroy
public function destroy(Comment $comment)
{
if ($comment->user_id != Auth::user()->id && !Entrust::hasRole('admin')) {
return redirect()->back()->withErrors(config('constants.INVALID_LINK'));
}
$belongs_to = $comment->belongs_to;
$comment->delete();
$activity = 'Deleted a commented on a ' . ucfirst($belongs_to);
Activity::log($activity);
return redirect()->back()->withSuccess(config('constants.DELETED'));
}
示例2: recursiveDestroy
/**
* Delete comment recursively
*
* @param \App\Comment $comment
* @return bool|null
*/
public function recursiveDestroy(Comment $comment)
{
if ($comment->replies->count()) {
$comment->replies->each(function ($reply) {
if ($reply->replies->count()) {
$this->recursiveDestroy($reply);
} else {
$reply->delete();
}
});
}
return $comment->delete();
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param Comment $comment
* @return \Illuminate\Http\Response
*/
public function destroy(Comment $comment)
{
if ($comment->user()->getResults() != Auth::user()) {
return response('Unauthorized.', 401);
}
return view('posts.show', compact($comment->delete()));
}
示例4: delete
public function delete(Request $request, Comment $comment)
{
$comment->delete($request->all());
flash('Your comment has been deleted.', 'error');
return back();
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy(Comment $comment)
{
$this->authorize('deleteComment', \Auth::user());
$comment->delete();
return redirect(route('article.show', [$comment->article->slug]))->with('flash_success', 'Комментарий успешно удален.');
}
示例6: destroy
public function destroy(Comment $comment)
{
$comment->delete();
return redirect('dash/comment')->with('message', 'Page was delete success.');
}
示例7: destroy
public function destroy(Post $post, Comment $comment)
{
$comment->delete();
return response(['url' => url('posts/' . $post->slug)]);
}
示例8: adminAnswerDelete
public function adminAnswerDelete(User $user, Comment $comment)
{
$comment->delete();
Flash::success(trans('admin/message.answerDeleted'));
return redirect()->back();
}
示例9: destroy
/**
* Remove the specified resource from storage, if run twice it permanently deletes it
*
* @param Comment $comment The comment you want to destroy
* @return Response
*/
public function destroy(Comment $comment)
{
if ($comment->user->id != Auth::user()->id && !Auth::user()->can('delete-comments')) {
abort(401, 'User does not have permission to delete this comment');
}
$comment->delete();
return $comment;
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy(RentalUnit $rentalUnit, Comment $comment)
{
$comment->delete();
}