Laravel 保存的日期不会显示在表单中

Laravel 保存的日期不会显示在表单中,laravel,laravel-8,Laravel,Laravel 8,我使用的是LaravelLiveWire,我已经创建了一个页面,您可以选择一个发布日期 出版。当我创建一篇新文章并保存日期时,它会很好地保存在数据库中,但如果我尝试 要编辑帖子并更改日期,我在数据库中保存的日期不会显示在表单中 这是我的密码。 我的EditPost.php <?php namespace App\Http\Livewire; use App\Models\Post; use Livewire\Component; class E

我使用的是LaravelLiveWire,我已经创建了一个页面,您可以选择一个发布日期 出版。当我创建一篇新文章并保存日期时,它会很好地保存在数据库中,但如果我尝试 要编辑帖子并更改日期,我在数据库中保存的日期不会显示在表单中

这是我的密码。 我的EditPost.php

    <?php

    namespace App\Http\Livewire;

    use App\Models\Post;
    use Livewire\Component;

    class EditPost extends Component
    {
        public $name;
        public $publishDate;

        public Post $post;

        public function mount(Post $post)
        {
            $this->name = $post->name;
            $this->publishDate = $post->publish_date;
        }
        public function render()
        {
            return view('livewire.edit-post');
        }
    }

您的日期格式是什么???@zahidhasanemon-是datetime您的输入类型是date。您正在将日期时间值放入其中。我将输入类型改为datetime local并创建了一个新帖子,但当我去编辑我的帖子时,它仍然没有显示出来
    <div>
        <div class="mt-10 sm:mt-0">
            <div class="md:grid md:grid-cols-3 md:gap-6">
                <div class="md:col-span-1">
                    <div class="px-4 sm:px-0">
                        <h3 class="text-lg font-medium leading-6 text-gray-900">Edit Post</h3>
                    </div>
                </div>
                <div class="mt-5 md:mt-0 md:col-span-2">
                    <div class="form">
                        <div class="shadow overflow-hidden sm:rounded-md">
                            <div class="px-4 py-5 bg-white sm:p-6">
                                <div class="grid grid-cols-6 gap-6">
                                    <div class="col-span-6 sm:col-span-3">
                                        <label for="name" class="block text-sm font-medium leading-5 text-gray-700">Name</label>
                                        <input id="name" wire:model="name" class="@error('name') border border-red-500 @enderror mt-1 form-input block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5">

                                        @error('name')
                                            <small>
                                                <div class="text-red-500">{{ $message }}</div>
                                            </small>
                                        @enderror
                                    </div>

                                    <div class="col-span-6 sm:col-span-4">
                                        <label for="publish_date" class="block text-sm font-medium leading-5 text-gray-700">Publish Date</label>
                                        <input id="publish_date" wire:model="publishDate" type="date" class="mt-1 form-input block w-full transition duration-150 ease-in-out sm:text-sm sm:leading-5">
                                    </div>
                                </div>
                            </div>
                            <div class="px-4 py-3 bg-gray-50 text-right sm:px-6">
                                <button wire:click="editPost" class="py-2 px-4 border border-transparent text-sm leading-5 font-medium rounded-md text-white bg-indigo-600 shadow-sm hover:bg-indigo-500 focus:outline-none focus:shadow-outline-blue active:bg-indigo-600 transition duration-150 ease-in-out">
                                    Save
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>