RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-248292

Moonwolf45's questions

Martin Hope
Moonwolf45
Asked: 2024-09-27 02:06:23 +0000 UTC

Laravel10 + VueJS3 UTF-8 字符格式错误,可能编码错误

  • 5

总的来说,几天前我在 laravel10 + vuejs3 上创建了一个应用程序。今天我写了一份授权说明并留下了请求,一切正常。安装扩展以使用jwt后,我将授权重写为:

public function login(LoginRequest $request): JsonResponse
{
    $credentials = $request->only('email', 'password');

    $token = Auth::attempt($credentials);
    if ($token === false) {
        return response()->json([
            'status' => 'error',
            'message' => 'Unauthorized',
        ], 401);
    }

    $user = Auth::user();
    return response()->json([
        'status' => 'success',
        'user' => $user,
        'authorisation' => [
            'token' => $token,
            'type' => 'bearer',
        ]
    ]);
}

答案开始下降,出现 500 错误, "Malformed UTF-8 characters, possibly incorrectly encoded" 错误本身指向这里。

file:"D:\\OpenServer\\domains\\my_project\\testLara\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\JsonResponse.php"
line: 88

有谁知道如何解决这个问题?

php
  • 2 个回答
  • 19 Views
Martin Hope
Moonwolf45
Asked: 2023-10-30 17:31:40 +0000 UTC

Laravel 授权

  • 5

我有一个 laravel 项目,在兰花中有一个管理面板,我更改了授权,但遇到了问题。我需要在登录时收到特定错误,但该怎么做?代码如下所示:

public function login(Request $request)
{
    $credentials = $request->validate([
        'email' => ['required', 'email'],
        'password' => ['required', 'string'],
    ]);

    $auth = $this->guard->attempt([
        'email' => $credentials['email'],
        'password' => $credentials['password'],
        'status' => User::$status['active']
    ], $request->filled('remember'));

    if ($auth) {
        return $this->sendLoginResponse($request);
    }

    throw ValidationException::withMessages([
        'email' => __('The details you entered did not match our records. Please double-check and try again.'),
        'password' => __('auth.password'),
        'status' => __('auth.status')
    ]);
}

现在如果有任何错误,那么我会收到所有 3 个错误。如何使用 attemp 方法找出具体错误是什么?或者我需要以不同的方式授权吗?

php
  • 1 个回答
  • 23 Views
Martin Hope
Moonwolf45
Asked: 2023-09-23 18:29:09 +0000 UTC

Laraver Orchid 上传至 Excel

  • 5

Laravel 8 上有一个项目,为管理面板安装了 Orchid,在一个页面上我将用户上传到 Excel 文件,此上传需要考虑已安装的过滤器。这就是我现在的文件的样子:

public function query(): iterable {
    return [
        'participant' => Profile::when(Auth::user()->organizer_id, function (Builder $query) {
            return $query->where('organizer_id', Auth::user()->organizer_id);
        })->filters()->defaultSort('id', 'desc')->paginate(),
    ];
}

public function commandBar(): iterable {
    return [
        Button::make('Выгрузить в Excel')
            ->method('export')
            ->icon('cloud-download'),
    ];
}

public function export(Request $request) {
    $profiles = Profile::when(Auth::user()->organizer_id, function (Builder $query) {
        return $query->where('organizer_id', Auth::user()->organizer_id);
    })->filters()->select('external_id', 'last_name', 'first_name', 'patronymic', 'phone', 'email', 'gender',
        'date_of_birth', 'status')->defaultSort('id', 'desc')->get();

    $fileArray = array_merge([['Внешний id', 'Фамилия', 'Имя', 'Отчество', 'Номер телефона',
        'Email', 'Пол', 'Дата рождения', 'Статус']], $profiles->toArray());

    $spreadsheet = new Spreadsheet();
    $activeWorksheet = $spreadsheet->getActiveSheet();
    $activeWorksheet->getStyle('A1:I' . count($fileArray))->getNumberFormat()
        ->setFormatCode(NumberFormat::FORMAT_TEXT);

    $widthColumn = '20';
    $activeWorksheet->getColumnDimension('A')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('B')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('C')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('D')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('E')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('F')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('G')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('H')->setWidth($widthColumn);
    $activeWorksheet->getColumnDimension('I')->setWidth($widthColumn);

    $activeWorksheet->fromArray($fileArray);

    $writer = new Xlsx($spreadsheet);

    return response()->streamDownload(function () use ($writer) {
        $writer->save('php://output');
    }, 'profiles.xlsx', [
        'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        'Content-Disposition: attachment;filename="profiles.xlsx"',
        'Cache-Control: max-age=0',
        'Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT',
        'Cache-Control: cache, must-revalidate',
        'Pragma: public'
    ]);
}

这有效并卸载了用户,但我无法想象如何传递数据以供过滤器导出。$request 中没有过滤数据。我需要你的帮助。

php
  • 1 个回答
  • 13 Views
Martin Hope
Moonwolf45
Asked: 2022-09-28 16:27:43 +0000 UTC

VueJs 点击箭头

  • 0

有一个在 vuejs 上生成的页面。有一个伪目录,每张卡片都有一个这样的 div:

<div class="b-catalog__select">
    <select class="b-select" name="" @change="setCurrentNominalForItem({id: item.id, val: $event.target})">
        <option :value="option.value" v-for="(option, index) in getNominals(item.id)" :key="'option_' + index">{{ option.label }}</option>
    </select>
</div>

b-catalog__select 块具有以下样式:

&__select {
  flex: 1 1 auto;
  position: relative;

  &::after {
    content: '\f107';
    border: 0;
    font: 800 32px 'Font Awesome';
    transform: none;
    transition: transform 0.1s linear;
    transform-origin: 50% 50%;
    color: #aaa;
    position: absolute;
    right: 0;
  }
}

一般来说,正如你从代码中看到的那样,我创建了一个穿过伪元素的箭头,一切都会好起来的,但是如果你按下它,它就不会按原样打开,因为 这是一个不同的元素。那么如何让它打开呢?最好不要将箭头创建为单独的组件。

vue.js
  • 1 个回答
  • 13 Views
Martin Hope
Moonwolf45
Asked: 2022-09-08 17:49:50 +0000 UTC

docker中的长命令

  • 0

一般来说,有这样一个问题,在一个在docker上工作的项目中,我写了一个通过composer下载插件的脚本文件,看起来是这样的:

docker exec -ti php sh -c "cd var/www/project/apps/tele2 && composer install"

一般来说,没什么复杂的,我们进入容器,将自己拖到所需的文件夹并下载指示的所有内容。问题本身是有很多图书馆,一段时间后我发现了一个错误。但是,如果您手动执行所有这些操作,则不会出现错误,并且所有内容都可以很好地下载。你怎么能解决这样一个奇怪的问题?

错误如下所示:

- Installing vlucas/phpdotenv (v2.6.9): Extracting archive
- Installing opis/closure (3.6.2): Extracting archive
- Installing yiisoft/yii2-debug (2.1.18): Extracting archive
- Installing phpspec/php-diff (v1.1.3): Extracting archive
- Installing yiisoft/yii2-gii (2.2.3): Extracting archive
37/75 [=============>--------------]  49%    Install of bower-asset/font-awesome failed
Install of mpdf/mpdf failed
Install of bower-asset/jquery-ui failed
Install of bower-asset/bootstrap failed
Install of phpoffice/phpspreadsheet failed
Install of goodby/csv failed
Install of imagine/imagine failed
Install of bower-asset/sweetalert failed
Install of symfony/process failed
The following exception is caused by a process timeout
Check https://getcomposer.org/doc/06-config.md#process-timeout for details

In Process.php line 1204:
                                                                                                                                                                                                                                    
The process "'/usr/bin/unzip' -qq '/var/www/project/apps/tele2/app/vendor/composer/tmp-a8ffef473a25eb18ded9c8fc075e9091' -d '/var/www/project/apps/tele2/app/vendor/composer/b231a75c'" exceeded the timeout of 300 seconds.          
                                                                                                                                                                                                                                    

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
docker cmd
  • 1 个回答
  • 41 Views
Martin Hope
Moonwolf45
Asked: 2022-08-28 20:53:30 +0000 UTC

Yii2 setFlash 正确消息输出

  • 0

一般来说,我在 yii2 上有一个项目,我在管理面板中编辑产品并且一切正常,然后我写下该人需要显示一条消息,即:

Yii::$app->session->setFlash('success', "Товар $model->title сохранен");

问题是由于某种原因,我必须在此之后刷新页面,以便所有保存的数据正确显示,但随后不再显示该消息。那么,这就是我如何让它在重启后出现??

Вывод сообщения:

<?php if (Yii::$app->session->getFlash('message')): ?>
    <div class="flash">
        <div class="alert alert-success alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4> <i class="icon fa fa-check"></i> <?= Yii::$app->session->getFlash('message') ?></h4>
        </div>
     </div>
 <?php endif ?>
php yii2
  • 1 个回答
  • 22 Views
Martin Hope
Moonwolf45
Asked: 2022-08-13 22:15:47 +0000 UTC

在js中对字符串数组进行排序

  • 0

一般来说,我在 vue 上有一个项目,在输出带有时区的数组之前,我对其进行排序。数组看起来像这样:

arrTimeZone:Array[415] {
  0:Object {
    text:"(+00:00) Абиджане, Кот-д'Ивуар"
    value:"Africa/Abidjan"
  },
  1:Object {
    text:"(+00:00) Аккра, Гана"
    value:"Africa/Accra"
  },
  ...

一般来说,从打印输出中可以看到,其中有 415 个,粗略地说,是 php.ini 中指定的所有区域。一般来说,排序后的数组是这样的,首先是+0,然后是+1,...,+12,最后是-0,-1等。

我是这样排序的:

timeZoneSort.sort(function (a, b) {
  if (a.text > b.text) {
    return 1
  }
  if (a.text < b.text) {
    return -1
  }
  return 0
});

正常的升序排序。问题是如何使缺点继续进行?这样数组以 -12 开始,以 +12 结束

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-07-22 23:47:58 +0000 UTC

VueJS从父级调用子方法

  • 1

一般来说,vueJs上有一个项目,我正在尝试从父级调用子组件的方法,但是有些事情没有解决。这是父组件中的内容:

<modalWindow :dialog="openFilter" :maxWidth="'720px'">
  <filterComponent ref="filterData" @callUpdateChartAndDataGrid="updateChartAndDataGrid" @callCloseModal="closeModal"></filterComponent>
</modalWindow>

<script>
    import ModalWindow from '@/components/Other/ModalComponent';
    import FilterComponent from '@/components/Other/FilterComponent';

...
onFilter () {
  this.openFilter = !this.openFilter;

  this.$refs.filterData.checkAllBills()
  this.$refs.filterData.checkAllCategories()
  this.$refs.filterData.checkAllCurrencies()
  this.$refs.filterData.checkAllTypes()
},
...

嗯,在孩子身上肯定有这样的方法,但是我得到以下错误:

vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading 'checkAllBills')

请帮忙。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-06-22 23:43:13 +0000 UTC

VueJs 计算数据和渲染

  • 1

一般来说,我正在用 VueJS 编写一个应用程序,我的代码中有这个东西:

<tbody v-if="currencies !== null && currenciesUser !== null">
  <tr v-for="currencyItem in currenciesUser" :key="currencyItem.id">
    <td>{{ $t(currencyItem.Name) }}</td>
    <td v-if="currencyItem.CharCode !== mainCurrency.CharCode && mainCurrency.CharCode === 'RUB'">
      {{ new Intl.NumberFormat(mainCurrency !== null ? mainCurrency.locale : 'ru-RU', { style: 'currency', currency: mainCurrency !== null ? mainCurrency.CharCode : 'RUB', minimumFractionDigits: 2, maximumFractionDigits: 2}).format(currencies.Valute[currencyItem.CharCode].Value / currencies.Valute[currencyItem.CharCode].Nominal) }}
    </td>
    <td v-else-if="currencyItem.CharCode !== mainCurrency.CharCode && mainCurrency.CharCode !== 'RUB'">
      {{ new Intl.NumberFormat(mainCurrency !== null ? mainCurrency.locale : 'ru-RU', { style: 'currency', currency: mainCurrency !== null ? mainCurrency.CharCode : 'RUB', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format((currencies.Valute[currencyItem.CharCode].Value / currencies.Valute[currencyItem.CharCode].Nominal) * (currencies.Valute[mainCurrency.CharCode].Value / currencies.Valute[mainCurrency.CharCode].Nominal)) }}
    </td>
    <td>{{ $moment(currencies.PreviousDate).format('DD.MM.YYYY HH:mm') }}</td>
  </tr>
</tbody>

在脚本代码中:

computed: {
  currencies () {
    return this.$store.getters.currencies
  },
  currenciesUser () {
    return this.$store.getters.currenciesUser
  },
  mainCurrency () {
    return this.$store.getters.mainCurrency
  }
}

事实上,一切都应该工作,但由于某种原因,我发现了一个错误:

TypeError: Cannot read properties of undefined (reading 'Value')
at eval (CurrencyCard.vue?4fd3:100:1)
at Proxy.renderList (vue.runtime.esm.js?2b0e:2630:1)
at Proxy.render (CurrencyCard.vue?4fd3:40:1)
at VueComponent.Vue._render (vue.runtime.esm.js?2b0e:3548:1)
at VueComponent.updateComponent (vue.runtime.esm.js?2b0e:4066:1)
at Watcher.get (vue.runtime.esm.js?2b0e:4479:1)
at Watcher.run (vue.runtime.esm.js?2b0e:4554:1)
at flushSchedulerQueue (vue.runtime.esm.js?2b0e:4310:1)
at Array.eval (vue.runtime.esm.js?2b0e:1980:1)
at flushCallbacks (vue.runtime.esm.js?2b0e:1906:1)

虽然 vuex 有这个数组,而且所有的检查都是值得的,但是还是会出现错误。怎么解决??

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-06-05 00:16:21 +0000 UTC

vuejs过滤器不起作用

  • 1

一般来说,我在 vuejs 上编写应用程序时遇到了这样的问题,我无法正确地从变量中提取数据。

这是代码:

<tbody v-if="currencies !== null && currenciesUser !== null">
  <tr v-for="currencyItem in currenciesUser" :key="currencyItem.id">
    <td>{{ $t(currencyItem.Name) }}</td>
    <td v-if="currencyItem.CharCode === 'RUB'">
      {{ new Intl.NumberFormat('ru-RU', { style: 'currency', currency: 'RUB',
        minimumSignificantDigits: 3 }).format(1) }}
    </td>
    <td v-else>
      {{ new Intl.NumberFormat(currencyItem.locale, { style: 'currency', currency: currencyItem.CharCode, minimumSignificantDigits: 3 }).format(currencies.Valute.filter(item => item.CharCode === currencyItem.CharCode).Value) }}
    </td>
    <td>{{ $moment(currencies.Date).format('DD.MM.YYYY HH:mm') }}</td>
  </tr>
</tbody>

我得到这个是这样的:

computed: {
  currencies () {
    return this.$store.getters.currencies
  },
  currenciesUser () {
    return this.$store.getters.currenciesUser
  }
}

在启动时我得到这个:

TypeError: _vm.currencies.Valute.filter is not a function

因此,没有任何输出。怎么赢??

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-05-07 19:32:11 +0000 UTC

确定搜索类型

  • 0

我有一个项目,我写了一个搜索来查找联系人,一般来说有一个问题,搜索通过代码、电话、电子邮件引导。我可以编写一个 sql 函数来搜索单个请求,但是有没有办法确定在哪个参数上找到匹配项,通过电话、电子邮件或代码?刚才我提出了 3 个请求,tk。考虑找到匹配的参数,然后我需要输出,即 如果是电话,则输出电话,电子邮件表示电子邮件等。

搜索代码如下所示:

public function searchContactByPhoneCodeEmailOrderId($search) {
    $search_condition = \cArray::stripQuotes([
        'code' => \cString::prepareSearchString($search),
        'email' => \cString::prepareSearchString($search),
        'phone' => $search
    ]);

    $type = 'code';
    $response_contact = cFactory::getDB()->getRows("
        SELECT TOP 15 
            ID_Code, 
            code, 
            ID_Contact
        FROM
            tblCode
        WHERE
            ID_Contact IS NOT NULL
            AND code LIKE '" . $search_condition['code'] . "%'
    ", __FILE__, __LINE__);

    if (empty($response_contact)) {
        $response_contact = cAuthorizationModel::model()->getContactByOldCode($search_condition['code']);
    }

    if (empty($response_contact) && cChecker::phone($search_condition['phone'])) {
        $type = 'phone';
        $response_contact = cFactory::getDB()->getRows("
        SELECT TOP 15 
            ID_Contact, 
            phone
        FROM
            tblContact
        WHERE
            phone LIKE '" . $search_condition['phone'] . "%'
    ", __FILE__, __LINE__);
    }
    ...
}

嗯,我觉得本质很清楚,就不写太多了。

sql
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-04-30 13:54:39 +0000 UTC

按 id 部分搜索

  • 0

如何使 sql 查询允许您按 id 部分搜索?

我有这样的代码:

return cFactory::getDB()->getRows("
        SELECT TOP 20
            ID_Order,
            ID_Contact
        FROM
            tblOrder
        WHERE
            ID_Contact IS NOT NULL
            AND ID_Order = ''
    ", __FILE__, __LINE__);

但是如果它只能用于字符串值,该怎么写WHERE呢?ID_Orderlike

sql
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-07-22 17:23:52 +0000 UTC

Yii2 Rest API 抛出异常

  • 0

一般来说,我有一个我在yii2中编写的api,我决定摆脱不必要的代码,如果在检查过程中出现错误则抛出异常,我这样做:

if ($ticket->tickets_left > $count_ticket) {
    $ticket->tickets_left -= $count_ticket;
    $hours = json_decode($ticket->schedule_minute);
    foreach ($hours as $hour) {
        if ($hour == (int)$order['hours']) {
            if ($hour->tickets_left > $count_ticket) {
                if ((int)$order['ticketsCount']['adults']) {
                    $total_price += ((int)$order['ticketsCount']['adults'] * $hour->price_adults);
                }
    
                if ((int)$order['ticketsCount']['students']) {
                    $total_price += ((int)$order['ticketsCount']['students'] * $hour->price_stud);
                }
    
                if ((int)$order['ticketsCount']['children']) {
                    $total_price += ((int)$order['ticketsCount']['kid'] * $hour->price_children);
                }
                $hour->tickets_left -= $count_ticket;
    
                foreach ($hour->minutes as $minute) {
                    if ($minute->minute == (int)$order['minutes']) {
                        if ($minute->count_ticket_left > $count_ticket) {
                            $minute->count_ticket_left -= $count_ticket;
                        } else {
                            return throw new UnprocessableEntityHttpException(Yii::t('app', 'Sorry, tickets for the selected time have run out'));
                        }
                    }
                }
            } else {
                return throw new UnprocessableEntityHttpException(Yii::t('app', 'Sorry, tickets for the selected time have run out'));
            }
        }
    }
} else {
    return throw new UnprocessableEntityHttpException(Yii::t('app', 'Sorry, tickets for the selected time have run out'));
}

就是这样,一切都应该工作,但这是我通过邮递员得到的回应:

ParseError: syntax error, unexpected &#039;throw&#039; (T_THROW), expecting &#039;;&#039; in 
D:\OpenServer\domains\iBrush\teleportAdmin\api\controllers\OrderController.php:90
Stack trace:
#0 [internal function]: yii\BaseYii::autoload()
#1 [internal function]: spl_autoload_call()
#2 D:\OpenServer\domains\iBrush\teleportAdmin\vendor\yiisoft\yii2\base\Module.php(643): class_exists()
#3 D:\OpenServer\domains\iBrush\teleportAdmin\vendor\yiisoft\yii2\base\Module.php(602): yii\base\Module-&gt;createControllerByID()
#4 D:\OpenServer\domains\iBrush\teleportAdmin\vendor\yiisoft\yii2\base\Module.php(594): yii\base\Module-&gt;createController()
#5 D:\OpenServer\domains\iBrush\teleportAdmin\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Module-&gt;createController()
#6 D:\OpenServer\domains\iBrush\teleportAdmin\vendor\yiisoft\yii2\web\Application.php(104): yii\base\Module-&gt;runAction()
#7 D:\OpenServer\domains\iBrush\teleportAdmin\vendor\yiisoft\yii2\base\Application.php(392): yii\web\Application-&gt;handleRequest()
#8 D:\OpenServer\domains\iBrush\teleportAdmin\web\index.php(12): yii\base\Application-&gt;run()
#9 {main}

基本上,我需要你的帮助。

php
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-07-21 00:47:11 +0000 UTC

PHP 使用 json

  • 0

一般来说,使用yii2的动态表单和多字段扩展,我将数据集存储在mysql中的json字段中,我为站点编写了一个api,我显示了所有这些东西,我格式化了数组,并尝试返回它,但是我有同样的 json 字符串,看起来像这样:

[
    {
        "hour": "14", 
        "minutes": [
            {"minute": "00", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "10", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "20", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "30", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "40", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "50", "count_ticket": 1, "count_ticket_left": 1}
        ], 
        "price_stud": "1", 
        "price_adults": "1", 
        "tickets_left": "6", 
        "count_tickets": "6", 
        "price_children": "1"
    }, {
        "hour": "15", 
        "minutes": [
            {"minute": "00", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "10", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "20", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "30", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "40", "count_ticket": 1, "count_ticket_left": 1}, 
            {"minute": "50", "count_ticket": 1, "count_ticket_left": 1}
        ], 
        "price_stud": "1", 
        "price_adults": "1", 
        "tickets_left": "6", 
        "count_tickets": "6", 
        "price_children": "1"
    }
]

一般来说,什么可以更简单,但由于某种原因,我被困在这一点上,我正试图像这样获得这个奇迹:

foreach ($scheduleTickets as $ticket) {
    $new_date_ticket = new DateTime($ticket['date']);
    $norm_date = $new_date_ticket->format('d.m.Y');
    if ((int)$ticket['status'] == Tickets::STATUS_ON) {
        $allowTickets[$norm_date] = [];
        $allowTickets[$norm_date]['tickets'] = (int)$ticket['tickets_left'];
        $allowTickets[$norm_date]['hours'] = [];
        if ((int)$ticket['tickets_left'] > 0) {
            $i = 0;
            Yii::info($ticket);
            Yii::info($ticket['schedule_minute']);
            foreach ($ticket['schedule_minute'] as $time_hour) {
                Yii::info($time_hour);
                $allowTickets[$norm_date]['hours'][$i]['value'] = (int)$time_hour->hour;
                $allowTickets[$norm_date]['hours'][$i]['label'] = (string)$time_hour->hour;
                $allowTickets[$norm_date]['hours'][$i]['tickets'] = $time_hour->tickets_left;
                $allowTickets[$norm_date]['hours'][$i]['price_children'] = $time_hour->price_children;
                $allowTickets[$norm_date]['hours'][$i]['price_stud'] = $time_hour->price_stud;
                $allowTickets[$norm_date]['hours'][$i]['price_adults'] = $time_hour->price_adults;
                $allowTickets[$norm_date]['hours'][$i]['minutes'] = [];
                if ((int)$time_hour->tickets_left > 0) {
                    $y = 0;
                    foreach ($time_hour['minutes'] as $time_minute) {
                        $allowTickets[$norm_date]['hours'][$i]['minutes'][$y]['value'] = (int)$time_minute->minute;
                        $allowTickets[$norm_date]['hours'][$i]['minutes'][$y]['label'] = (string)$time_minute->minute;
                        $allowTickets[$norm_date]['hours'][$i]['minutes'][$y]['tickets'] = $time_minute->count_ticket_left;
                        $y++;
                    }
                }
                $i++;
            }
        }
    }
}

一般来说,我需要你的帮助,如何访问这些数据?

php
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-02-14 23:32:33 +0000 UTC

VueJs 突出显示的菜单项

  • 1

我有一个用 写的菜单vue,如下所示:

<router-link v-for="(item, i) in menu" :key="i" :to="item.path" custom v-slot="{ navigate }">
    <v-list-item @click="navigate" @keypress.enter="navigate" role="link">
        <v-list-item-icon>
            <v-icon>{{ item.icon }}</v-icon>
        </v-list-item-icon>

        <v-list-item-content>
            <v-list-item-title>{{ $t(item.name) }}</v-list-item-title>
        </v-list-item-content>
    </v-list-item>
</router-link>

我怎样才能使它立即拥有我要去的项目,嗯,更准确地说,当我浏览这些项目时,它们被突出显示,但是我通过从另一个模板重定向到第一个项目并且它没有突出显示. 一般来说,我该怎么做?

这是里面的内容menu:

data () {
  return {
    menu: [
      { path: '/', name: 'main.bill', icon: 'account_balance_wallet' },
      { path: '/history', name: 'main.history', icon: 'history' },
      { path: '/planning', name: 'main.planning', icon: 'business_center' },
      { path: '/records', name: 'main.recording', icon: 'add_box' },
      { path: '/settings', name: 'main.settings', icon: 'settings' }
    ],
  }
}
vue.js
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-02-11 00:27:58 +0000 UTC

Yii2 Rest api 无法获取 POST 数据

  • 0

一般来说,我以这种方式向api发送数据:

axios.post(environment.url + '/api/v1/users/registration', payload, { headers }).then(res => {
    console.log(res);
}).catch(err => {
    console.log(err);
})

但是当尝试像这样从 yii2 中获取时:

$user['bodyParams'] = Yii::$app->request->getBodyParams();

我得到一个空数组,但我这样做是这样的:

$user['raw'] = Yii::$app->request->getRawBody();

然后我可以将数据作为字符串获取,但这不适合我。

如何通过 POST 正常获取数据?

php
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2022-02-08 20:16:48 +0000 UTC

Yii2 模块路由

  • 0

我正在 yii2 中编写一个 api 模块并使用子模块进行版本控制。问题是我无法访问子模块中的页面,我只是得到404。这就是我在配置中描述的方式:

'modules' => [
    'api' => [
        'basePath' => '@app/api',
        'class' => app\api\ApiModule::class,
        'modules' => [
            'v1' => [
                'basePath' => '@app/api/v1',
                'class' => app\api\v1\V1Module::class,
            ]
        ],
        'components' => [
            'request' => [
                'class' => 'yii\web\Request',
                'parsers' => [
                    'application/json' => 'yii\web\JsonParser',
                ],
                'enableCsrfValidation' => false,
                'enableCsrfCookie' => false,
            ],
            'response' => [
                'class' => 'yii\web\Response',
                'formatters' => [
                    \yii\web\Response::FORMAT_JSON => [
                        'class' => 'yii\web\JsonResponseFormatter',
                        'prettyPrint' => YII_DEBUG,
                        'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
                    ]
                ]
            ]
        ]
    ],
],
...
'urlManager' => [
        'enablePrettyUrl' => true,
        'enableStrictParsing' => true,
        'showScriptName' => false,
        'rules' => [
            ['class' => 'yii\rest\UrlRule', 'controller' => ['api/v1/user']],

            '/' => 'site/index',
        ],
    ],

需要你的帮助。

php
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2021-10-26 21:32:33 +0000 UTC

php数组排序

  • 2

一般来说,我在yii2上有一个项目,有一个多对多关系的类别,我写了一个小部件,可以选择它们并按应有的方式排列它们,我需要按字母顺序对所有类别进行排序,我做它是这样的:

protected function getTree () {
    $tree = [];
    foreach ($this->data as $id => &$node) {
        if ($node['category_id_1'] == 0) {
            $tree[$node['categoryId2']['id']] = &$node['categoryId2'];
        } else {
            $tree[$node['category_id_1']]['childs'][$node['categoryId2']['id']] = &$node['categoryId2'];
        }
    }

    uasort($tree, function ($a, $b) {
        $lower_a = mb_strtolower($a['name']);
        $lower_b = mb_strtolower($b['name']);

        if ($lower_a == $lower_b) {
            return 0;
        }
        return ($lower_a < $lower_b) ? -1 : 1;
    });
    for ($i = 0; $i < count($tree); $i++) {
        if (!empty($tree[$i]['childs'])) {
            uasort($tree[$i]['childs'], function ($a, $b) {
                $lower_a = mb_strtolower($a['name']);
                $lower_b = mb_strtolower($b['name']);

                if ($lower_a == $lower_b) {
                    return 0;
                }
                return ($lower_a < $lower_b) ? -1 : 1;
            });
        }
    }

    return $tree;
}

粗略地说,在我建立了一个类别树之后,我对它进行了排序,但我只对父类别进行了排序,出于某种原因,孩子们没有改变。需要帮忙。

php
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2020-09-11 19:43:05 +0000 UTC

vk api message.send 发送链接

  • 1

一般来说,我正在为 VK 开发一个机器人,因此有必要发送一个链接。在电报中,要发送链接,您需要启用它parse_mode,但我没有为 VKontakte 找到类似的东西,如果您只是插入链接,它将作为字符串发送。我使用扩展发送。LukasAndreano/VKBotAPI需要帮助,如何发送链接?

php
  • 1 个回答
  • 10 Views
Martin Hope
Moonwolf45
Asked: 2020-09-08 20:56:22 +0000 UTC

Telegram Bot 无法发送链接

  • 0

我正在通过webhook一个项目为电报编写一个机器人yii2,我安装了插件aki/yii2-bot-telegram。纯文本发送正常,但是链接有问题。我创建这样的链接:

$text .= 'Ссылка на диалог: <a href="' . Yii::$app->params['baseUrl'] . '/#/dialogs/' . $dialog['id'] . '">' . Yii::$app->params['baseUrl'] . '/#/dialogs/' . $dialog['id'] . '</a>' . "\n";
$text .= 'Или отправьте ответ на это сообщение для ответа пользователю.';

我这样发送:

Yii::$app->telegram->sendMessage([
    'chat_id' => $chat_id,
    'text' => $text,
    'parse_mode' => 'HTML',
    'disable_web_page_preview' => true
]);

也试过发送到Markdown,自然是用他求链接的阵型。结果是一样的——纯文本来了。怎么修?

php
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5