Sorry, I have a question, maybe it's something very simple but I feel like I already locked myself in my mistake and I can not see another solution The question is this: I have my tables or migrations: * ranges
Schema::create('rangos', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('inicio');
$table->unsignedInteger('final');
$table->timestamps();
});
* articles
Schema::create('articulos', function (Blueprint $table) {
$table->increments('id');
$table->string('codigo');
$table->string('SKU');
$table->string('descripcion',75)->unique();
$table->double('precioUnitario');
$table->boolean('a_venta');
$table->boolean('a_inventario');
$table->boolean('a_compra');
$table->boolean('act_fijo');
$table->string('file',128)->nullable();
$table->unsignedInteger('id_grupo');
$table->unsignedInteger('id_area');
$table->unsignedInteger('id_clase');
$table->unsignedInteger('id_lista');
$table->foreign('id_grupo')->references('id')->on('grupos')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('id_area')->references('id')->on('areas')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('id_clase')->references('id')->on('clases')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('id_lista')->references('id')->on('lista_precios')->onDelete('cascade')->onUpdate('cascade');
$table->timestamps();
});
* articulo_rango
Schema::create('articulo_rango', function (Blueprint $table) {
$table->increments('id');
$table->double('precio');
$table->unsignedInteger('articulo_id');
$table->unsignedInteger('rango_id');
$table->timestamps();
//relaciones
$table->foreign('articulo_id')->references('id')->on('articulos')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('rango_id')->references('id')->on('rangos')->onDelete('cascade')->onUpdate('cascade');
});
Then when making my factory and my seeds
I generate false data but I can not enter what is the price attribute in my database
this is my seed
factory(App\Articulo::class, 160)->create()->each(function(App\Articulo $articulo){
$articulo->rango()->attach([
rand(1,5),
rand(6,15),
rand(16, 23),
]);
});
I clarify already believes the belongsToMany
* this is in my model article
public function rango(){
return $this->belongsToMany(Rango::class)->withPivot('precio');
}
* this is in my model range
public function articulo(){
return $this->belongsToMany(Articulo::class)->withPivot('precio');
}
I hope and help me to generate my false data
I'm new to this .. greetings