简体   繁体   中英

Laravel QueryException / SQLSTATE[42S02]

I'm new to Laravel and have an error.
When I try to check my page, I get this error:

QueryException in Connection.php line 713: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_tcc.colaboradors' doesn't exist (SQL: select * from colaboradors order by id_colaborador asc)

My table name is 'colaboradores', I know the error is 'colaboradors', but I dont know where is that 'colaboradors' in my project files.
I need to find in the code to fix, but I dont have idea what file take care of sql in laravel.

My model for colaboradores:

<?php
    namespace App;
    use Illuminate\Database\Eloquent\Model;
    class Colaborador extends Model {
        protected $fillable = array('id_colaborador','nome','rg','orgao_expedidor','cpf','estado_civil','sexo','nome_pai','nome_mae','natura‌​lidade','data_nascimento','login','senha','siape','pis','rua','numero','bairro',‌​'cidade','estado','cep','telefone_fixo','telefone_celular','telefone_comercial','email');
    }

My controller : http://pastebin.com/QYgRBRrc

The "snake case", plural name of the class will be used as the table name unless another name is explicitly specified.

So this is your issue.

You have two options:

  • Either rename your model class or
  • Add in your model $table = 'colaboradores';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM