i'm using laravel 5.2 and i need get the id of the newly created object in the same function in a controller to create another object with this attribute.
This is the function in the controller:
public function store(Request $request)
{
Movie::create([
'usuario_id' => $request['usuario_id'],
'asignatura_id' => $request['asignatura_id'],
'name' => $request['name'],
'visit' => $request['visit'],
'language' => $request['language'],
]);
Subtitle::create([
'url' => $request['subtitle'],
]);
return "OK";
}
I need the id of this Movie to create a new Subtitle because the id is a foreign key in Subtitle. Thanks for the answers.