【问题标题】:Undefine Method in Laravel-5?Laravel-5 中的未定义方法?
【发布时间】:2018-10-31 20:38:07
【问题描述】:

请谁能告诉我如何解决这个错误。我是 laravel 的新手,所以我无法理解这些方法。请帮我解决这个错误。

未定义的方法 Illuminate\Database\Query\Builder::edit()

请帮助我或告诉我为什么会出现此错误。

【问题讨论】:

  • 请在这里写一些代码。
  • 请发布您的代码
  • 公共函数 viewCv($id) {$user=Applicants::where('id',$id)->first();if($user->cvUrl != ""){ return response()->file(storage_path('app/'.$user->cvUrl));}else{return redirect('home')->with('status','Resume not Found.');} }public function edit($id){$applicant = 申请人::find($id);$applicant->edit();return redirect('home')->with('status','Employee Edited'); }public function delete($id){$applicant = 申请人::find($id);$applicant->delete();return redirect('home')->with('status','Employee Deleted.') ;}}
  • 请将代码添加到您的问题中,而不是评论区

标签: php html css mysql laravel


【解决方案1】:

您尝试功能更新。 在 Illuminate\Database\Query\Builder 中有函数

/**
 * Update a record in the database.
 *
 * @param  array  $values
 * @return int
 */
public function update(array $values)
{
    $sql = $this->grammar->compileUpdate($this, $values);

    return $this->connection->update($sql, $this->cleanBindings(
        $this->grammar->prepareBindingsForUpdate($this->bindings, $values)
    ));
}

【讨论】:

    【解决方案2】:

    简单的更新方法示例:

    Route('/update/profile/{id}','UserController@updateData');
    
    public function updateData(Request $request){
    
       $value = ModelName::find($request->id);
       $value->name = $request->name;
       $value->email = $request->email;
       $value->nickaname = $request->nickaname;
       $value->save();
    }
    

    【讨论】:

      猜你喜欢
      • 2016-06-05
      • 2016-05-10
      • 1970-01-01
      • 1970-01-01
      • 2017-03-20
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 2016-01-22
      相关资源
      最近更新 更多