I have this little annoying problem trying to delete a row in a paginated grid in Laravel, which worked fine a few days ago, and NOW, i'm getting this problem in all my grids whenever I try to delete any record. Here's an example of the error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.id'
in 'where clause' (SQL: delete from `users` where `id` = 9)
Now my actual code:
Migration up()
Schema::create('users', function(Blueprint $table){
$table->increments('id');
$table->string('username', 50);
$table->string('password', 50);
$table->string('email', 50);
$table->tinyInteger('roles_id');
$table->string('remember_token', 255);
$table->timestamps();
});
View
{{ Form::open(array('action' => array('UserController@delete_user'), 'method' => 'delete')) }}
{{ Form::submit('Delete', array('class'=>'btn btn-danger', 'title'=>'Delete', 'style'=>'width:70px;height:35px;margin-left:100px;')) }}
{{ Form::hidden('id','',array('id'=>'identifier')) }}
{{ Form::close() }}
Route
Route::delete('users/delete', array('uses'=>'UserController@delete_user'))->before('auth');
Controller UserController
public function delete_destroy(){
$id = Input::get('id');
User::findOrFail($id)->delete();
return Redirect::route('users');
}
Model User
class User extends Eloquent implements UserInterface, RemindableInterface {
protected $table = 'users';
protected $hidden = array('password');
protected $fillable = array('username', 'email', 'password', 'roles_id');
public static $accessible = array('username', 'email', 'roles_id');
private static function rules(){
return array(
'username' => 'required|min:6|max:20|unique:users,username,"'.Input::get('id').'"',
'password' => 'required|min:8',
'email' => 'required|email',
'roles_id' => 'required|numeric|min:1',
);
}
//Bunch of other native functions
}
That's pretty much how all my routes, views, models and controllers look.
I'm only having trouble with deleting records though, creating and updating works fine.
Delete was working fine up until a few days ago, when I last deleted a record.
Today I was trying something different in a view, going from create to update, then when I tried to delete it, the previously quoted error message came up.