小编Mat*_*rre的帖子

升级到laravel 5.3后出错无效日期时间格式:1292日期时间值不正确:'0000-00-00 00:00:00'

我将项目从5.2升级到laravel 5.3.现在,当我想要运行时,php artisan migrate我收到错误:SQLSTATE [22007]:无效的日期时间格式:1292日期时间值不正确:第1行的'created_at'列的'0000-00-00 00:00:00'(SQL:alter table messagesadd deleted_attimestamp空值).我的迁移:

  Schema::table(Models::table('messages'), function (Blueprint $table) {
        $table->softDeletes();
  });
Run Code Online (Sandbox Code Playgroud)

在Blueprint.php中:

    public function softDeletes()
    {
        return $this->timestamp('deleted_at')->nullable();
    }
Run Code Online (Sandbox Code Playgroud)

migration timestamp date laravel

8
推荐指数
2
解决办法
8634
查看次数

如何始终使用 withTrashed() 进行模型绑定

在我的应用程序中,我对很多对象使用软删除,但我仍然想在我的应用程序中访问它们,只是显示一条特殊消息,表明该项目已被删除并提供恢复它的机会。

目前我必须对 RouteServiceProvider 中的所有路由参数执行此操作:

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {


        parent::boot();

        Route::bind('user', function ($value) {
            return User::withTrashed()->find($value);
        });

        Route::bind('post', function ($value) {
            return Post::withTrashed()->find($value);
        });

        [...]


    }
Run Code Online (Sandbox Code Playgroud)

是否有更快更好的方法将废弃的对象添加到模型绑定中?

laravel eloquent laravel-5.5

5
推荐指数
2
解决办法
5531
查看次数

使用 Dropzone 和 Laravel 获取要上传的图像

我正在尝试创建一个页面,用户可以在其中添加标题,然后上传图像或 2。我正在使用 dropzone 和 Laravel,我试图让它看起来不同,我让它看起来像http:// www.dropzonejs.com/bootstrap.html

我遇到的问题是我需要向 js 文件添加一个 url,但它一直给我这个错误

POST http://crud.test/portfolios 419(状态未知)

并在我的开发工具中的预览中

{消息:“”,异常:“Symfony\Component\HttpKernel\Exception\HttpException”,...}

我知道在 Laravel 中我会使用

{{ csrf_field() }}
Run Code Online (Sandbox Code Playgroud)

并且我无法将图像上传到我在控制器中指定的文件夹或将图像保存到我的数据库中。

我想要的是如何让我的图像上传到文件夹并保存到我的数据库。

我的刀片:

<form action="{{ route('portfolios.store') }}">
    {{ csrf_field() }}

    <div class="form-group">
        <label>Title</label>
        <input type="title" name="title" class="form-control">
    </div>

    <div id="actions" class="row">
        <div class="col-lg-7">
            <span class="btn btn-success fileinput-button dz-clickable">
                <i class="glyphicon glyphicon-plus"></i>
                <span>Add files...</span>
            </span>

            <button type="button" class="btn btn-info start">
                <i class="glyphicon glyphicon-upload"></i>
                <span>Start upload</span>
            </button>

            <button type="reset" class="btn btn-warning cancel">
                <i class="glyphicon glyphicon-ban-circle"></i>
                <span>Cancel upload</span>
            </button>
        </div>

        <div …
Run Code Online (Sandbox Code Playgroud)

laravel dropzone.js laravel-5 dropzone

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