php - 我如何解决迁移 Voyager(管理面板)时发生的此异常 BadMethodCallException date_time_set 不存在
问题描述
BadMethodCallException : Method
Illuminate\Database\Schema\Blueprint::date_time_set does not exist.
at
// C:\wamp64\www\NewsApp\vendor\laravel\framework\src\Illuminate\Support \Traits\Macroable.php:104 100| */ 101| 公共函数 __call($method, $parameters) 102| {103| if (!static::hasMacro($method)) {
104| throw new BadMethodCallException(sprintf( 105| '方法 %s::%s 不存在。', static::class, $method 106| )); 107| } 108|
Exception trace:
1 Illuminate\Database\Schema\Blueprint::__call("date_time_set")
C:\wamp64\www\NewsApp\database\migrations
\2019_10_28_194406_create_posts_table.php:20
2 CreatePostsTable::{closure}
(Object(Illuminate\Database\Schema\Blueprint))
C:\wamp64\www\NewsApp\vendor\laravel\framework\src
\Illuminate\Database\Schema\Builder.php:166
Please use the argument -v to see more details.
//2019_10_28_194406_create_posts_table.php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePostsTable extends Migration
{
/**
* Run the migrations.
*
* @return void'category_id'
*/
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('content');
$table->date_time_set('Date');
$table->text('image') ->nullable();
$table->integer('votes_up') -> nullable();
$table->integer('votes_down') ->nullable();
//relationships
$table->integer('user_id');
$table->integer('category_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
}
解决方案
你在迁移文件上错了行
$table->date_time_set('Date');
改成:
$table->dateTime("date");
推荐阅读
- memory-management - 如果我在 VM 选项中设置了两个 Xms 值,那么选择哪一个?
- python - Python 文件在 VSCode 中工作,但在作为可执行文件运行时会自动崩溃
- google-cloud-firestore - Firestore 快照侦听器是否会返回未完成的写入操作而无法进行这些写入操作?
- javascript - Vue.js - 我有动态按钮,如果我点击一个按钮,我希望颜色会改变
- flutter - 我想让男孩的内容在颤动中滚动
- ajax - jquery ui draggable droppable 动态问题
- google-apps-script - 如何在 Google 表格中获取多行的注释
- node.js - mongo 中的嵌套字段更新(更新查询中的更新)
- docker - 如何让 OracleDB 与 Express 连接?
- java - Checkstyle-IDEA IntelliJ 插件在应该时没有显示问题