samedi 22 septembre 2018

Laravel: I'm adding a specialty to each therapist in my database and this shows up. Why?

enter image description here

<?php


public function up()
{
    Schema::create('specialties', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name')->unique;
        $table->timestamps();
    });

    Schema::create('t_specialties', function (Blueprint $table) {

        $table->integer('therapist_id');
        $table->integer('spec_id');
        $table->primary(['therapist_id','spec_id']);
        $table->timestamps();
    });
}

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

And my model looks like this

class Therapist extends Model
{
    protected $fillable = ['image'] ;

    public function specialty()
    {
        return $this->belongsToMany(Specialty::class);
    }
}

The method I'm using is similar to adding Tags in a blog but every time I try to tinker in cmd, I end up with the error in the photo above. I can't seem to understand what's the problem :(



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire