Вот как мы можем получить последний вставленный id в Laravel 4
public function store()
{
$input = Input::all();
$validation = Validator::make($input, user::$rules);
if ($validation->passes())
{
$user= $this->user->create(array(
'name' => Input::get('name'),
'email' => Input::get('email'),
'password' => Hash::make(Input::get('password')),
));
$lastInsertedId= $user->id; //get last inserted record's user id value
$userId= array('user_id'=>$lastInsertedId); //put this value equal to datatable column name where it will be saved
$user->update($userId); //update newly created record by storing the value of last inserted id
return Redirect::route('users.index');
}
return Redirect::route('users.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
}
Я думаю, что вы можете привязать свойство (предположим, оно называется SelectedIdx) в ViewModel к SelectedIndex, режим привязки можно выбрать OneWayToSourc или TwoWay.
Итак, когда вы выбрали один элемент, ваша viewModel получит selectedIndex через SelecteIdx.