John Davidson

php - Row in database is NULL and I dont know why

0 comments
Message:


I have a controller to add some data on my database. All is working excepted one row.


Here is my code :


View :


    <div class="form-group">
<label for="exampleInputEmail1">Logo</label>
<input type="text" class="form-control" name="logo">


Controller :


Vpns::create([
'title' => $request->title,
'intro' => $request->intro,
'content' => $request->content,
'jeux' => $jeux,
'chine' => $request->chine,
'torrent' => $request->torrent,
'netflix' => $request->netflix,
'nolog' => $request->nolog,
'securite' => $request->securite,
'paiement' => $request->paiement,
'systemes' => $request->systemes,
'appareils' => $request->appareils,
'lien' => $request->lien,
'url' => $request->url,
'meilleur_prix' => $request->meilleur_prix,
'duree_abo' => $request->duree_abo,
'logo' => $request->logo]
);

In my form I put a string in row "logo" but in database it appears as "NULL", I don't know why...


Migrations :


public function up()
{
Schema::table('vpns', function (Blueprint $table) {
$table->string('logo')->nullable();
});
}

Thanks for help



My Answer:







Controller :
public function addData(Request $request)
{
$data = new Data;
$data->name = $request->name;
$data->email = $request->email;
$data->save();
return redirect()->back();
}
Model :
class Data extends Model
{
protected $table = 'data';
protected $fillable = ['name', 'email'];
}
Migration :
Schema::create('data', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->timestamps();
});
When I submit the form, the data is added to the database but the "email" field is always NULL. I have checked the form and the controller, everything seems fine. What could be the issue here?

Rate this post

5 of 5 based on 3853 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us