我有这个QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into `comentarios` (`NombreUsuario`, `CorreoUsuario`, `TelefonoUsuario`, `Asunto`, `Mensaje`, `FecComentario`, `updated_at`, `created_at`) values (Andres, poc@dw.xom, 124422432, Andres es genial, vffgdf, 2016-11-20 03:34:45, 2016-11-20 03:44:18, 2016-11-20 03:44:18))
这是我的laravel 5.1的SQL
public function store(Request $request)
{
\JuanSapo\ContadorT::create([
'NombreUsuario' => $request['nombres'],
'CorreoUsuario' => $request['email'],
'TelefonoUsuario' => $request['numContacto'],
'Asunto' => $request['asunto'],
'Mensaje' => $request['mensaje'],
'FecComentario' => $request['fecha']
]);
return view('contacto');
}
我可以看到,我最后还有两个日期,看看我的错误,
这是我的auth.php
<?php
return [
'driver' => 'eloquent',
'model' => JuanSapo\User::class,
'model' => JuanSapo\ContadorT::class,
'table' => 'users',
'table' => 'comentarios',
'password' => [
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
],
];
这是我的User.php
<?php
namespace JuanSapo;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
protected $table = 'users';
protected $fillable = ['name', 'email', 'password'];
protected $hidden = ['password', 'remember_token'];
}
这是我的contadotT.php
<?php
namespace JuanSapo;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class ContadorT extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
protected $table = 'comentarios';
protected $fillable = ['NombreUsuario', 'CorreoUsuario', 'TelefonoUsuario','Asunto','Mensaje','FecComentario'];
protected $hidden = ['contador'];
}
答案 0 :(得分:1)
您必须在public $timestamps = false;
模型类中添加ContadorT
,因此Laravel不会添加crated_at
&amp;查询中的update_at
个字段