Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更新/保存Laravel 5中的职位_Laravel_Laravel 5 - Fatal编程技术网

更新/保存Laravel 5中的职位

更新/保存Laravel 5中的职位,laravel,laravel-5,Laravel,Laravel 5,我也按照我的想法做了同样的工作,但是当我点击更新按钮时,我得到了一个空白视图(空白浏览器) 控制器 公共功能编辑($id) { $job=job::whereId($id)->firstOrFail(); 返回视图('jobs.edit')->withJob($job); } 公共功能更新($id) { $job=job::whereId($id)->firstOrFail(); $job->fill(输入::all()); $job->save(); flash(“您已成功编辑您的工作帖子”)

我也按照我的想法做了同样的工作,但是当我点击更新按钮时,我得到了一个空白视图(空白浏览器)

控制器

公共功能编辑($id)
{
$job=job::whereId($id)->firstOrFail();
返回视图('jobs.edit')->withJob($job);
}
公共功能更新($id)
{
$job=job::whereId($id)->firstOrFail();
$job->fill(输入::all());
$job->save();
flash(“您已成功编辑您的工作帖子”);
返回重定向('/jobs'$id);
}
编辑视图

{!!Form::model($job,array('method'=>'PATCH','route'=>array('jobs.update',$job->id)))
{!!Form::label('job_title','title')
{!!Form::text('job_title',null,array('class'=>'Form control'))
{!!Form::label('job_description','description')
{!!Form::text('job_description',null,array('class'=>'Form control'))!!}
{!!表单::提交('Update Job Post!',数组('class'=>'btn btn primary'))
{!!Form::close()!!}
路线

Route::resource('jobs','JobsController');

一只额外的眼睛和清晰的大脑可以帮助我解释为什么我的编辑不起作用。

这很奇怪,因为我的应用程序中只有很少的部分我必须使用
\Input
,而其他部分我只使用
Input
。对于这种情况,这解决了答案:
$job->fill(\Input::all())

您自己提供的答案是正确的,但是为了向未来的读者澄清这一点,我将回答为什么的问题


任何具有名称空间的类都需要通过名称空间访问外观,名称空间就是
\
。因此,如果您的类(例如控制器或模型)以
开头,只需将更新函数更改为以下内容-

  public function update($id)
{
    $job =  \App\User::whereId($id)->firstOrFail();
    $job->fill(\Input::all());
    $job->save();

    flash('You have successfully edited your Job Post');

    return redirect('/');
}

希望它能正常工作

返回重定向('/jobs'$id)Job::findOrFail($id)
而不是
Job::whereId($id)->firstOrFail()@ConradWarhol谢谢你这么做,但如果成功的话,我会找到一些找不到的页面,但这并没有解决问题;)谢谢你的澄清。
  public function update($id)
{
    $job =  \App\User::whereId($id)->firstOrFail();
    $job->fill(\Input::all());
    $job->save();

    flash('You have successfully edited your Job Post');

    return redirect('/');
}