2
votes

I have made my controller to insert data into my database and Task is the model file.

app/http/controller/UsersTableController:

public function store() {
    $user = new Task;
    $user->name = Input::get('name');
    $user->PhoneNo = Input::get('PhoneNo');
    $user->password = Hash::make(Input::get('password'));
    $user->save();
    return Redirect::to('/')->with('success','You have been successfully subscribe to us.');
}

Task model:

<?php
    namespace App;
   use Illuminate\Database\Eloquent\Model;
   class Task extends \Eloquent
   {
       protected $table ='users';
       public $timestamp =  'false';
   }

My route:

Route::post('/PostForm', array('uses'=>'UsersTable@store'));

and my form through which I want to save the data into data base saved as Register.blade.php

<form action="PostForm" method="post">
  First name: <input type="text" name="name"><br>
  Phone Number: <input type="number" name="PhoneNo"><br>
  Password: <input type="password" name="password" mak=8>
  <button type="submit">Submit</button><br>
</form>

and what I'm getting on my browser screen when I'm pressing submit button....

QueryException in Connection.php line 651: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into users (name, PhoneNo, password, updated_at, created_at) values (romiii, 9876543210, asderf, 2015-12-23 10:02:56, 2015-12-23 10:02:56))

and

PDOException in Connection.php line 390: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list'

1

1 Answers

1
votes

To stop Eloquent from automatically handling timestamps, you need to set the $timestamps attribute to false.

public $timestamps = false

Note that you're setting it to a string, which does not evaluate to a boolean false.