标签: laravel-6.2

Laravel 6:限制密码重置

在 laravel 6 中,密码代理现在有以下限制密码重置(https://github.com/laravel/framework/blob/6.x/src/Illuminate/Auth/Passwords/PasswordBroker.php#L58

public function sendResetLink(array $credentials)
{
    // First we will check to see if we found a user at the given credentials and
    // if we did not we will redirect back to this current URI with a piece of
    // "flash" data in the session to indicate to the developers the errors.
    $user = $this->getUser($credentials);

    if (is_null($user)) {
        return static::INVALID_USER;
    }

    if (method_exists($this->tokens, 'recentlyCreatedToken') &&
        $this->tokens->recentlyCreatedToken($user)) {
        return static::RESET_THROTTLED;
    }

    // Once we have …
Run Code Online (Sandbox Code Playgroud)

throttling forgot-password laravel-6.2

5
推荐指数
1
解决办法
5993
查看次数

如何在 Laravel 6 及以上版本中安装 Whoops

我从5.4 开始就一直在研究 Laravel 框架

这是 Laravel 版本和错误处理程序的历史

  • 4.0 - 4.2 - 费拉/哎呀
  • 5.0 - 5.4 - symfony/错误处理程序
  • 5.5 - 5.8 -菲尔普/呐喊

并且随着Laravel 6.0 的发布,他们引入了名为Ignition的新错误页面

https://github.com/facade/ignition

这个包内置了高级调试。但显然这是由VueJS完成的。

所以在 Postman 中调试 Api 请求时,我没有在预览中得到任何东西。

那么有没有办法在 Laravel 6.0 和未来版本中切换到 Whoops

因为即使在旧版本的 Laravel 项目中也有切换到 Ignition 的选项

使用下面的代码 app/Exceptions/Handler.php

protected function whoopsHandler()
{
    try {
        return app(\Whoops\Handler\HandlerInterface::class);
    } catch (\Illuminate\Contracts\Container\BindingResolutionException $e) {
        return parent::whoopsHandler();
    }
}
Run Code Online (Sandbox Code Playgroud)

php laravel whoops laravel-6 laravel-6.2

4
推荐指数
1
解决办法
2119
查看次数

1292 列 'updated_at' 的日期时间值不正确

我在 Laravel 中创建了一个带有标准日期时间列的表:

Schema::create('lists', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('name');
    $table->string('ref');
    $table->string('provider');
    $table->timestamps();
    $table->softDeletes();

    $table->unique(['provider', 'ref']);
});
Run Code Online (Sandbox Code Playgroud)

当我尝试使用 Eloquent 创建一个简单的记录时:

List::updateOrCreate([
    'provider' => 'test',
    'ref'      => 'S4d3g'
], [
    'name' => 'Plan'
]);
Run Code Online (Sandbox Code Playgroud)

我收到此消息(这是原始控制台输出,因此请忽略缺少引号):

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2020-03-08 02:25:07' for column 'updated_at' at row 1 (SQL: insert into `lists` (`provider`, `ref`, `name`, `updated_at`, `created_at`) values (test, S4d3g, Plan, 2020-03-08 02:25:07, 2020-03-08 02:25:07))
Run Code Online (Sandbox Code Playgroud)

在数据库上手动运行查询作为原始 SQL 也不起作用:

insert into `lists` (`provider`, `ref`, `name`, `updated_at`, `created_at`) values ('test', …
Run Code Online (Sandbox Code Playgroud)

mysql laravel laravel-6.2

4
推荐指数
1
解决办法
4245
查看次数

Laravel 在哪里存储油门数据?

我使用 Laravel 速率限制(节流)。我想知道它在哪里存储节流数据以及如何将默认存储系统更改为 MySQL/Mariadb 或 Redis?

php throttling laravel laravel-6.2

3
推荐指数
1
解决办法
654
查看次数

Log in on 3rd party website using Laravel Passport

I need to solve the following problem: I created two applications using Laravel.

  • Application A can be reached via https://test.example.org and provides a passport-instance and all user-data (Model: User).
  • Application B can be reached via https://test.org and uses the API Application A provides using an "api-user" that exists in Application A to fetch "public" data

Now I would like to provide a login method for users of Application B. All users that are using Application B are existing …

laravel laravel-passport laravel-6 laravel-6.2

2
推荐指数
1
解决办法
1028
查看次数

如何在 Windows 上为“php artisan”命令创建自己的别名?

我看过创建自己别名的文档,但它有点令人困惑。任何人都可以帮助我并简单地告诉我该怎么做吗?我认为它会帮助很多人,因为我在 stackoverflow 上看到的与此相关的问题很少,但真的很难得到。谢谢你。

php laravel laravel-6.2

1
推荐指数
2
解决办法
2803
查看次数

Passport 和 Auth::logout() 产生意外错误

我使用Laravel 6.7 和 Passport来使用我自己的 API。当我尝试使用 注销用户时Auth::logout(),出现以下错误:

Illuminate\Auth\RequestGuard::logout 不存在。

我不明白为什么我会有这样的行为。我没有使用任何定制的守卫。根据 Passport 设置,我的Auth.php如下:

<?php

return [
    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
        ],
    ],
Run Code Online (Sandbox Code Playgroud)

这是我的 AuthenticationController.php 注销代码所在的位置:

/**
     * --------------------------------------------------
     * Removes the identity of a users login session.
     * --------------------------------------------------
     * @param Request $request
     * @return MessageResource
     * -------------------------------------------------- …
Run Code Online (Sandbox Code Playgroud)

laravel-passport laravel-6.2

1
推荐指数
1
解决办法
989
查看次数

Laravel 验证的最佳实践

我创建新的表单请求并将其用于所有 CRUD 操作

并用于$this->getMethod();检查请求之间的差异

然后我面临逻辑问题

  1. 更新方法中是否需要store 方法中需要的所有字段?

    => 这里的问题是 API 的消费者是否应该发送所有密钥对象来更新特定密钥

  2. 如果不应该,并且从 API 发送的键名与数据库表列名不同

    => 我不能使用,update($request()->all());因为键与列名不同,然后我需要循环所有请求键以忽略具有空值的键 - 也可以通过多检查来完成-

那么请问最好的做法是什么?

php api laravel laravel-5.8 laravel-6.2

1
推荐指数
1
解决办法
3435
查看次数

Laravel 6.2:$request-&gt;all() 返回一个空数组

我使用 Postman 在 Laravel Api 中发送请求,并且返回一个空数组。而且我不知道为什么?

\n\n

我的路线:

\n\n
Route::middleware('auth:api')->group( function () {\n\n    Route::resource('reservations', 'ReservationController');\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的预订控制器:

\n\n
    <?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse App\\Http\\Requests\\ReservationCreateRequest;\nuse App\\Repositories\\ReservationRepository;\nuse App\\Http\\Resources\\Reservation as ReservationResource;\n\nclass ReservationController extends BaseController\n{\n\n    protected $entrepriseRepository;\n\n    public function __construct(ReservationRepository $reservationRepository)\n    {\n        $this->reservationRepository = $reservationRepository;\n    }\n\n    /**\n     * Display the specified resource.\n     *\n     * @param  int  $id\n     * @return \\Illuminate\\Http\\Response\n     */\n    public function show($id)\n    {\n        $reservation = $this->reservationRepository->getById($id);\n\n        return $this->sendResponse(new ReservationResource($reservation), 'Reservation');\n    }\n\n    /**\n     * Update the specified resource in storage.\n     *\n     * @param  Illuminate\\Http\\Request $request\n …
Run Code Online (Sandbox Code Playgroud)

ajax json request laravel laravel-6.2

1
推荐指数
1
解决办法
3811
查看次数

在 Laravel 包中注册 vue 组件

我一直在努力在我自己为 Laravel 开发的测试包中注册 vue 组件。我什至检查了 laravel\horizo​​n 和其他一些软件包,但我不知道该怎么做。我正在关注Laravel 包开发

所以我的包在我的 Laravel 应用程序之外。我的包结构如下:

vendor
    packagename
        resources
            js
                components
                    examplecomponent.vue
                app.js
        AppServiceProvide.php
        package.json
        webpack.mix.js
Run Code Online (Sandbox Code Playgroud)

对于 vue 组件来说,这只是 Laravel 的示例,对于 app.js 来说,基本上没有改变任何东西,因为它只是用于测试目的。我尝试使用“vendor:publish”命令将 vue 组件复制到 resources\js\compnents,它正在复制它,但仍未在 app.js 中注册。所以问题是在 Laravel 包或供应商中注册 vue 组件的最佳方式是什么?Laravel Horizo​​n 包如何注册它的组件,我确实检查了 Laravel/horizo​​n 的所有代码源,没有像“npm run”这样的命令或复制组件并将其添加到主应用程序中的某个位置,就像 npm 正在检查一样供应商文件在 laravel/horizo​​n 中搜索 package.json 文件,然后注册组件。如果是这样,为什么我的 vue 组件没有注册。

laravel vue.js laravel-6.2

1
推荐指数
1
解决办法
3441
查看次数