git reset --hard HEAD@{1}
HEAD@{1}
git reset HEAD~1
'paid_back_at' => [
function (string $attribute, mixed $value, Closure $fail) {
if ($value !== null) {
$fail("The {$attribute} is invalid.");
}
},
],
https://laravel.com/docs/10.x/validation#using-closures <?php
enum CurrenciesEnum: string
{
case RUB = 'RUB';
case USD = 'USD';
case EUR = 'EUR';
case GBP = 'GBP';
case JPY = 'JPY';
case CNY = 'CNY';
private const DATA = [
'RUB' => ['name' => 'Рублей', 'short' => '₽', 'ratio' => 1, 'default' => 1, 'display' => 1],
'USD' => ['name' => 'Dollar', 'short' => '$', 'ratio' => 1, 'default' => 1, 'display' => 1],
'EUR' => ['name' => 'Euro', 'short' => '€', 'ratio' => 1, 'default' => 1, 'display' => 1],
'GBP' => ['name' => 'Pound', 'short' => '£', 'ratio' => 1, 'default' => 1, 'display' => 1],
'JPY' => ['name' => '円', 'short' => '¥', 'ratio' => 1, 'default' => 1, 'display' => 1],
'CNY' => ['name' => '元', 'short' => 'Ұ', 'ratio' => 1, 'default' => 1, 'display' => 1],
];
public function code(): string
{
return $this->value;
}
public function name(): string
{
$this->insureValue();
return self::DATA[$this->value]['name'];
}
public function short(): string
{
$this->insureValue();
return self::DATA[$this->value]['short'];
}
public function ratio(): string
{
$this->insureValue();
return self::DATA[$this->value]['ratio'];
}
public function default(): string
{
$this->insureValue();
return self::DATA[$this->value]['default'];
}
public function display(): string
{
$this->insureValue();
return self::DATA[$this->value]['display'];
}
private function insureValue(): void
{
if (!isset(self::DATA[$this->value])) {
throw new InvalidArgumentException($this->value);
}
}
}
echo CurrenciesEnum::RUB->code(), PHP_EOL;
echo CurrenciesEnum::RUB->name(), PHP_EOL;
echo CurrenciesEnum::RUB->short(), PHP_EOL;
<?php
enum CurrenciesEnum
{
case RUB;
case USD;
case EUR;
case GBP;
case JPY;
case CNY;
public function code(): string
{
return $this->name;
}
public function name(): string
{
return self::getField($this->name, 'name');
}
public function short(): string
{
return self::getField($this->name, 'short');
}
public function ratio(): string
{
return self::getField($this->name, 'ratio');
}
public function default(): string
{
return self::getField($this->name, 'default');
}
public function display(): string
{
return self::getField($this->name, 'display');
}
private static function getField(string $currency, string $field): string
{
$data = [
self::RUB->name => ['name' => 'Рублей', 'short' => '₽', 'ratio' => 1, 'default' => 1, 'display' => 1],
self::USD->name => ['name' => 'Dollar', 'short' => '$', 'ratio' => 1, 'default' => 1, 'display' => 1],
self::EUR->name => ['name' => 'Euro', 'short' => '€', 'ratio' => 1, 'default' => 1, 'display' => 1],
self::GBP->name => ['name' => 'Pound', 'short' => '£', 'ratio' => 1, 'default' => 1, 'display' => 1],
self::JPY->name => ['name' => '円', 'short' => '¥', 'ratio' => 1, 'default' => 1, 'display' => 1],
self::CNY->name => ['name' => '元', 'short' => 'Ұ', 'ratio' => 1, 'default' => 1, 'display' => 1],
];
if (!isset($data[$currency])) {
throw new InvalidArgumentException($currency);
}
return $data[$currency][$field];
}
}
echo CurrenciesEnum::RUB->code(), PHP_EOL;
echo CurrenciesEnum::RUB->name(), PHP_EOL;
echo CurrenciesEnum::RUB->short(), PHP_EOL;
final class Currency
{
public function __construct(
readonly string $code,
readonly string $name,
readonly string $short,
readonly int $ratio = 1,
readonly int $default = 1,
readonly int $display = 1,
)
{
}
}
final class CurrenciesStorage
{
private static self|null $instance = null;
/** @var Currency[] */
private array $currencies = [];
private function __construct()
{
}
public static function getInstance(): self
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
public function add(Currency $currency): void
{
$this->currencies[$currency->code] = $currency;
}
public function has(string $code): bool
{
return isset($this->currencies[$code]);
}
public function get(string $code): Currency|null
{
return $this->currencies[$code] ?? null;
}
public function all(): array
{
return $this->currencies;
}
}
$storage = CurrenciesStorage::getInstance();
$storage->add(new Currency('RUB', 'Рублей', '₽'));
$storage->add(new Currency('USD', 'Dollar', '$'));
$storage->add(new Currency('EUR', 'Euro', '€'));
// Получить данные по одному объекту
echo $storage->get('RUB')->code, PHP_EOL;
echo $storage->get('RUB')->name, PHP_EOL;
echo $storage->get('RUB')->short, PHP_EOL;
// Получить все объекты
var_dump($storage->all());
INSERT INTO table (field1, field2, field3) VALUES (value1, value2, value3), (value4, value5, value6), (value7, value8, value9)
const axios = require('axios')
export default {
methods: {
getCounters (count = 1, time = '', start) {
axios.get(this.url + 'counters/' + this.server + '/?count=' + count + '&time=' + (time || '&noCache=' + (new Date().getTime()) + Math.random()))
.then((res) => {
this.currentData= res.data[0]
})
.catch((err) => {
this.queryError = 'Нет ответа от сервера'
})
},
stopTimer () {
if (this.interval) {
window.clearInterval(this.interval)
}
},
startTimer () {
this.stopTimer()
this.interval = window.setInterval(() => {
this.getCounters()
}, 1000)
}
},
mounted () {
this.startTimer()
},
beforeDestroy () {
this.stopTimer()
}
}
const { GoogleSpreadsheet } = require('google-spreadsheet');
const apiKey = API_KEY; // Ключ для работы с Google SpreadSheet API
const findId = "234567"; // Искомый номер
const spreadSheetId = "1PWuqvPkqB7gFEe1l7vXOvWdFkqbNAN6IsbP_9gUM1mE"; // ID таблицы в гуглодоках
(async () => {
const doc = new GoogleSpreadsheet(spreadSheetId );
await doc.useApiKey(apiKey);
await doc.loadInfo();
const sheet = doc.sheetsByIndex[0];
const rows = await sheet.getRows();
const point = rows.find(row => row._rawData[0] == findId)._rawData[1];
console.log(point);
})();