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)); }
/** * 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); }