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