0
I have a small problem in the production of a registration system, everything is working fine, but when I check the database no data submitted in the form appears, ie is not registered.
Class in the Controller:
public function Submit(Request $request)
{
Model::create($request ->all());
return redirect()->action('MainController@index');
}
Observing: I won’t put the View because she’s too big (has about 150 lines of code, only the form, but if necessary I put.)
Their respective model:
class Model extends Model
{
protected $table = 'user';
public $timestamps = false;
protected $fillable = array('nome',
'CPF',
'email',
'datnasc',
'naturalidade',
'turno',
'uf_natural',
'nome_mae',
'nome_pai',
'nome_resp',
'cpf_resp',
'rua',
'numero',
'bairro',
'complemento',
'cep',
'didade',
'estado',
'tel_celular',
'tel_fixo',
'tipo_escola',
'escola_origem',
'serie');
protected $guarded = ['id'];
}
How to solve this problem?
Gives a dd($request ->all()); before Model::create($request ->all()); and p checks if the data is being submitted. Also check the form action
– Marcos Xavier
Form field names are the same as the database that were filled in the variable
$fillable?– Ademir Mazer Jr - Nuno
That’s how it is:
class Model extends Modelif you have is a bad practice because Model is already reserved by Eloquent define its classes, so do not make any class with the name ofModel? In your View you could put only the part of<form></form>and their routes too!– novic
No, it’s just a generic name. !
– Plinio Fabrycio