Good afternoon, I use Laravel 5.3 as a back-end for a project and I will try to explain the problem more succinctly.
Problem : In my project I have the Duplicate model and the Contract.
In the database I have the tables:
duplicatas
contratos
They all share basically the same code
$duplicata = new Duplicata()
$duplicata->valor = $request->valor
$duplicata->descricao = $request->descricao
$duplicata->contrato_id = $request->contrato_id
$duplicata->save()
But now I'm going to add our Number to the database, and I'll have to copy and paste the programming logic into all 3 controllers.
And I find this a bad programming practice and I intend to unify the way in which duplicates are created, but how do I do this? Am I doing everything wrong?