app\models\Player::setTexture PHP Method

setTexture() public method

Set textures for the player.
public setTexture ( array $tids ) : mixed
$tids array
return mixed
    public function setTexture(array $tids)
    {
        foreach (self::$models as $model) {
            $property = "tid_{$model}";
            if (isset($tids[$property])) {
                $this->{$property} = $tids[$property];
            }
        }
        $this->last_modified = Utils::getTimeFormatted();
        $this->save();
        return Event::fire(new PlayerProfileUpdated($this));
    }

Usage Example

コード例 #1
0
 /**
  * A wrapper of Player::setTexture()
  */
 public function setTexture(Request $request)
 {
     foreach ($request->input('tid') as $key => $value) {
         if (!($texture = Texture::find($value))) {
             return json(trans('skinlib.un-existent'), 6);
         }
         $field_name = "tid_{$texture->type}";
         $this->player->setTexture([$field_name => $value]);
     }
     return json(trans('user.player.set.success', ['name' => $this->player->player_name]), 0);
 }