John Davidson

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


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 :

'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) {

Thanks for help

My Answer:

Controller :
public function addData(Request $request)
$data = new Data;
$data->name = $request->name;
$data->email = $request->email;
return redirect()->back();
Model :
class Data extends Model
protected $table = 'data';
protected $fillable = ['name', 'email'];
Migration :
Schema::create('data', function (Blueprint $table) {
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

3 of 5 based on 6125 votes


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