Table to be created the virtual calculated column. The total column is just an example of what I expect
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('price');
$table->integer('total')->virtualAs(sum(lots.total))->defalt(0); // virtualAs Or virtualAs
});
Second table
Schema::create('lots', function (Blueprint $table) {
$table->id();
$table->string('description');
$table->decimal('price');
$table->integer('total') ;
$table->integer('product_id'); //relationship
});
I would like to obtain the sum of the lots in the total product column