本文整理汇总了PHP中app\Post::whereAuthorIP方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::whereAuthorIP方法的具体用法?PHP Post::whereAuthorIP怎么用?PHP Post::whereAuthorIP使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::whereAuthorIP方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLastPostForIP
/**
* Returns the last post made by this user across the entire site.
*
* @static
* @param string $ip
* @return \App\Post
*/
public static function getLastPostForIP($ip = null)
{
if (is_null($ip)) {
$ip = new IP();
}
return Post::whereAuthorIP($ip)->orderBy('created_at', 'desc')->take(1)->get()->first();
}
示例2: getMod
/**
*
*/
public function getMod(Request $request, Board $board, Post $post)
{
if (!$post->exists) {
abort(404);
}
// Take trailing arguments,
// compare them against a list of real actions,
// intersect the liss to find the true commands.
$actions = ["delete", "ban", "all", "global"];
$argList = func_get_args();
$modActions = array_intersect($actions, array_splice($argList, 2));
sort($modActions);
$ban = in_array("ban", $modActions);
$delete = in_array("delete", $modActions);
$all = in_array("all", $modActions);
$global = in_array("global", $modActions);
if (!$ban && !$delete) {
return abort(404);
}
if ($ban) {
if ($global && !$this->user->canBanGlobally()) {
return abort(403);
} else {
if (!$this->user->canBan($board)) {
return abort(403);
}
}
return $this->view(static::VIEW_MOD, ["actions" => $modActions, "form" => "ban", "board" => $board, "post" => $post, "banMaxLength" => $this->option('banMaxLength')]);
} else {
if ($delete) {
if ($global) {
if (!$this->user->canDeleteGlobally()) {
return abort(403);
}
$posts = Post::whereAuthorIP($post->author_ip)->with('reports')->get();
$this->log('log.post.delete.global', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "ip" => $post->getAuthorIpAsString(), "posts" => $posts->count()]);
Post::whereIn('post_id', $posts->pluck('post_id'))->delete();
foreach ($posts as $post) {
Event::fire(new PostWasModerated($post, $this->user));
}
} else {
if (!$this->user->canDelete($post)) {
return abort(403);
}
if ($all) {
$posts = Post::whereAuthorIP($post->author_ip)->where('board_uri', $board->board_uri)->with('reports')->get();
$this->log('log.post.delete.local', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "ip" => $post->getAuthorIpAsString(), "posts" => $posts->count()]);
Post::whereIn('post_id', $posts->pluck('post_id'))->delete();
foreach ($posts as $post) {
Event::fire(new PostWasModerated($post, $this->user));
}
} else {
if (!$post->isAuthoredByClient()) {
if ($post->reply_to) {
$this->log('log.post.delete.reply', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "op_id" => $post->op->board_id]);
} else {
$this->log('log.post.delete.op', $post, ["board_id" => $post->board_id, "board_uri" => $post->board_uri, "replies" => $post->replies()->count()]);
}
}
$post->delete();
Event::fire(new PostWasModerated($post, $this->user));
}
}
return back();
}
}
return abort(403);
}