Laravel findOrNew - 如何重定向取决于发生的事情

I am using Laravel 5 on my local machine. I am using findOrNew and I want to redirect the user differently depending on what happened. This is my code so far

$contact = Contact::findOrNew($id);
$contact->user_id = Auth::user()->id;
$contact->first_name = Request::get('first_name');
$contact->save();

return redirect('path/here')->with('message', 'my_message_here');

As you can see, if a new contact has been added or if contact has been modified, I do the same redirect. But what if I want to redirect the user if a new row has been created? Same thing if contact has been modified, I want the user to redirected on another page. Thx!

Finally I found a way to do this. I think my code doesn't need any explanation, it is so easy to understand!

$contact = Contact::findOrNew($id);

// get the id if contact exists. If he doesn't, $latest_id will be NULL.
$latest_id = $contact->id;

$contact->user_id = Auth::user()->id;
$contact->first_name = Request::get('first_name');
$contact->save();

// check if id is the same as the contact above
if($latest_id == $contact->id) {
    return redirect('different/path')->with('message', 'another message');
}
return redirect('path/here')->with('message', 'my_message_here');

I ran into this problem also using laravel 5.1. I over thought it for a few minutes before I found the boolean exists attribute. When a model is found exists === true else exists === false. This works consistently even if your tables have primary keys not named 'id'.

Simply can do it. $id is previous contact id and $contact->id is latest id

if($id == $contact->id) {   // if $id==$contact->id then data updated else data inserted
    return redirect('path1')->with('message', 'Update Message');
}
return redirect('path2')->with('message', 'Insert Message');