So I have my driver
public function store(Request $request)
{
$marca = MarcaAuto::create(['marca' => $request->marca ]);
ModeloAuto::create([
'modelo_auto' => $request->modelo,
'year_model' => $request->year,
'marca_auto_id' => $marca->id(),
]);
Model MarcaAuto
(table1)
class MarcaAuto extends Model
{
protected $table ='marca_auto';
protected $fillable = ['marca'];
public $timestamps = false;
public function modelo_auto()
{
return $this->hasMany(ModeloAuto::class);
}
}
Model of Auto Model (Table2)
class ModeloAuto extends Model
{
protected $table ='';
protected $fillable = [
'modelo_auto',
'year_model',
'marca_auto_id'];
public $timestamps = false;
public function modelo_parte_motor()
{
return $this->hasMany(ModeloParteMotor::class);
}
public function marca_auto()
{
return $this->belongsTo(MarcaAuto::class);
}
}
This is the error that gives me:
Call to undefined method Illuminate \ Database \ Query \ Builder :: id ()