lundi 26 décembre 2016

Save insterts empty row Laravel 5.3

Hi Im trying to make Laravel ORM working and it keeps inserting empty records in database. The ID created_at and updated_at are correctly inserted but the values are not. Here are the files :

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class TesterTest extends Model
{    
    protected $fillable = ['name','value'];
    public $name;
    public $value;
}

The migration file:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTestTable extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
     public function up()
    {
        Schema::create('my_tests', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->integer('value');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('my_tests');
    } }

And this is how Im calling it:

$flight = new TesterTest;

$flight->name = "Tester1";

$flight->save();

There is a something Im missing but cant figure it out.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire