vendredi 27 novembre 2015

Laravel 5.1: Get ID from firstOrNew method

I have the following function which creates a new record in the database if one doesn't already exists - if one exists, it updates it. The problem is that it returns true and therefore I can't get the ID of the inserted or updated record.

/**
 * Save timesheet.
 *
 * @param $token
 * @param $data
 */
public function saveTimesheet($token, $data) 
{
    return $this->timesheet->firstOrNew($token)->fill($data)->save();
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Ra6ZSb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire