Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column not found: 1054 Unknown column laravel

Tags:

php

mysql

laravel

so i trying to make a form with laravel but other than in new version they removed form ! but i can get this running

so here is is :

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

and my blade :

{{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))
like image 557
Greatone Avatar asked Dec 24 '14 14:12

Greatone


1 Answers

This is happens because Laravel assumes you want to use the updated_at and created_at timestamps for your models. So it also assumes they exist in the database. You can either create the two columns or disable timestamps for your model by adding

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();
}
like image 119
lukasgeiter Avatar answered Oct 12 '22 02:10

lukasgeiter