Example #1
0
 /**
  * Update the specified resource in storage.
  *
  * Mark: Because the relation is hasOne, info returns an Object not a Collection,
  * So it works, or if the relation is hasMany, info returns a Collection Object,
  * It will not work
  *
  * Mark: If it is not an object,Calling update will ignore fillable variable.
  *
  * @param  int $id
  * @return Response
  */
 public function update(InfoRequest $request, User $user)
 {
     if ($this->isMe($user)) {
         if ($user->info->update($request->all())) {
             Flash::success('修改成功!');
             return View::make($this->getView('edit'))->withUser($user);
         } else {
             Flash::error('修改失败!');
             return Redirect::back()->withInput();
         }
     }
 }