Hello I have a little question about relacional models 1:N and how can I assign the Foreign Key.
public function CreateAction(){
$id = 3;
$part = Parts::findFirst($id); // Looking for my specific record (FK) to assign later
$robot = new Robots();
$robot->name = "Ironman";
$robot->type = "5289756";
$robot->id_parts = $part->id_parts; // Here is the Question - Is it a good practice?
// $robots->id_parts = Local Column FK
$robot->save(); //Save Data
}
Really I don't know If I am following a good practice to assign FK to a Object (model) or no?
Do exist other ways?
Thanks!