我是 Laravel 开发的新手,正在尝试创建一个由 SQLite 数据库支持的 Eloquent 模型。我的本地开发服务器上有以下代码,它正确地接受请求,构建模型,并将该模型保存为callback_requests 表中的一行。
下面是模型定义文件和数据库迁移文件。我已经使用运行迁移
php artisan migrate:reset --force
php artisan migrate
Run Code Online (Sandbox Code Playgroud)
回调请求.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class CallbackRequest extends Model
{
public $name;
public $phone;
public $email;
public $preferredTime;
}
Run Code Online (Sandbox Code Playgroud)
create_callback_requests_table(迁移).php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCallbackRequestsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('callback_requests', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('phone');
$table->string('email');
$table->string('preferredTime');
$table->string('name');
});
}
/**
* Reverse the migrations.
* …Run Code Online (Sandbox Code Playgroud)