所以我试图用laravel制作一个表单,但除了在新版本中,他们删除了表单!但我可以让它运行

下面是:

Route::post('/register', function()
{
    $user = new User;
    $user-> u_n = Input::get('u_n');
    $user->save();
    return View::make('thanks')->with('theEmail',$theEmail);
});

还有我的刀刃:

{{Form::open(array('url'=>'register'))}}

username : {{Form::label('u_n', 'E-Mail Address');}}
{{Form::text('u_n');}}
{{Form::submit('');}}

u_n is name of my mysql data base field and this is the actual error :

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into `users` (`u_n`, `updated_at`, `created_at`) values (sepehr, 2014-12-24 14:32:55, 2014-12-24 14:32:55))

推荐答案

这是因为Laravel假设您希望为模型使用updated_atcreated_at时间戳.因此,它还假设它们存在于数据库中.您可以创建这两列,也可以通过添加

public $timestamps = false;

Laravel Docs

By the way: If you're using migrations, adding the timestamp columns is a breeze.

Schema::table('table_name', function(Blueprint $table){
    $table->timestamps();
}

Laravel相关问答推荐

AJAX响应中未定义的全名

按回车键时如何防止此功能运行?

在 Laravel 中清除 Routes&config:cache 后未定义的常量

调用字符串上的成员函数

给定的角色或权限应该使用 guard `` 而不是 `web`. -Laravel

如何在laravel中将数组转换为字符串?

错误try 访问 null 类型值的数组偏移量laravel 5.8.26 Php 7.4.2

判断 Laravel 模型表中是否存在列,然后应用条件

从 laravel/blade 中的数组创建逗号分隔列表?

你如何找到 Laravel 外观背后的底层类?

如何判断是否在laravel中设置了cookie?

Laravel 5.1 重命名项目

如何在包中安排 Artisan 命令?

加载模型的所有关系

如何在 laravel 中解码 Json 对象并在 laravel 中应用 foreach 循环

在Lumen框架中启用会话

命令未定义异常

脚本 php artisan clear-compiled 处理 pre-update-cmd 事件返回错误(Laravel 4.1 升级)

在 Laravel 中结合 AND/OR Eloquent的查询

使用 Nginx 设置 Laravel