vendredi 4 janvier 2019

How to get the id of newly inserted data in a pivot?

I have this code:

$candidate = Applicant::find($request->candidate_id);
$candidate->jobOrders()->syncWithoutDetaching($job_id);

I want to return the id of the inserted data. So far the solution I saw was querying the last inserted data in the pivot table.

Is there other easier or more efficient way to retrieve the id?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Qq5DG3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire