I have a problem with firstOrNew()
method of the Laravel eloquent class. the problem is that when I give the method some attributes and values and call save()
on the model, it doesn't get saved (inserted or updated).
PHP :
<?
$flightModel = Flight::firstOrNew([
'arrival' => $flightData['arrival'],
'plane' => $flightData['plane']
]);
$flightModel->departure = $flightData['departure'];
$flightModel->save();//this doesn't save any data
But when I try this with a new model it gets saved :
<?
$flightModel = new Flight();
$flightModel->arrival = $flightData['arrival'];
$flightModel->plane = $flightData['plane'];
$flightModel->departure = $flightData['departure'];
$flightModel->save();
Thanks for helping.