我如何解决迁移 Voyager(管理面板)时发生的异常 BadMethodCallException date_time_set 不存在
How can i solve this Exception that occurs when i migrate my Voyager (admin panal ) BadMethodCallException date_time_set does not exist
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| public 函数 __call($方法, $参数)
102| {
103|如果(!static::hasMacro($方法)){
104| throw new BadMethodCallException(sprintf(
105| 'Method %s::%s does not exist.', static::class,
$method
106| ));
107| }
108|
Exception trace:
1 Illuminate\Database\Schema\Blueprint::__call("date_time_set")
C:\wamp64\www\NewsApp\database\migrations
19_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");
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| public 函数 __call($方法, $参数) 102| { 103|如果(!static::hasMacro($方法)){
104| throw new BadMethodCallException(sprintf( 105| 'Method %s::%s does not exist.', static::class, $method 106| )); 107| } 108|
Exception trace:
1 Illuminate\Database\Schema\Blueprint::__call("date_time_set")
C:\wamp64\www\NewsApp\database\migrations
19_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");