本文整理汇总了PHP中Character::latestVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Character::latestVersion方法的具体用法?PHP Character::latestVersion怎么用?PHP Character::latestVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character
的用法示例。
在下文中一共展示了Character::latestVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acceptChanges
public function acceptChanges(Character $character)
{
if ($character->in_review) {
$character->approved_version = $character->latestVersion()->version;
$character->in_review = false;
//Inactivate all other characters this player owns.
if (!$character->owner->isStoryteller()) {
$was_active = $character->active;
foreach (Character::where('user_id', $character->owner->id)->get() as $c) {
$c->active = false;
$c->save();
}
$character->active = true;
if (!$was_active) {
//This is a new character
$character->owner->sendMessage(null, "New Character Accepted", "The Storytellers have accepted your character \"" . $character->name . "\"." . " Any of your characters that were previously active have been inactivated." . " You have been granted access to your new clan's forum, and access to your old" . " clan forum has been revoked. If you have any questions, please post in the " . " \"General Messages\" forum.");
$character->approved_at = new DateTime();
$xp_cost = $character->getExperienceCost(1);
$character->experience -= 10 - $xp_cost;
Cache::forget("character-experience-{$character->id}");
$character->save();
} else {
$character->owner->sendMessage(null, "Changes to " . $character->name . " Accepted", "The Storytellers have accepted your changes to \"" . $character->name . "\"." . " You can now access your character and make further changes as necessary.");
}
}
$character->save();
}
Cache::forget('forum-listing-' . $character->owner->id);
return Redirect::to($_SERVER['HTTP_REFERER']);
}