lundi 1 avril 2019

How to get Last ID of created data from related model?

I can't fetch last id of created data from related model.

I tried to use $alacarte->id but it doesnt get the right ID of the model.

$order = array(
            'os_id' => $orderSlip->id,
            'group_id' => $menu['group_id'],
            'size' => $menu['size'],
        );


$alacarte = $this->menu->find($menu['id']);

$alacarte->orders()->create($order)->save();

return $alacarte->id;

I expect the output of the last created order to be the ID of Model\Order, but the actual output is the ID of the Model\Menu.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2VfqUpf
via IFTTT

Aucun commentaire:

Enregistrer un commentaire