当我在projects
列表中编辑项目时,它不会编辑当前项目,但它会添加一个新项目,而保留“原始项目”,而不是编辑项目
我的代码出了什么问题?
控制器:
class ProjectController extends Controller
{
private $project;
public function __construct(Project $project){
$this->project = $project;
// $this->project = $project
// ->with('user');
}
public function getUsersTotal () {
$project_users = DB::table('users')
->select('browser')
->groupBy('browser')
->get();
}
public function index()
{
$projects = Project::get();
return view('project.index', array('projects' => $projects));
}
public function create()
{
return view('project.create');
}
public function store(CreateProjectRequest $request, Project $project)
{
$project->create($request->all());
return redirect()->route('project.index');
}
public function show($id)
{
//
}
public function edit($id)
{
$project = $this->project->find($id);
return view('project.edit', ['project' => $project, 'id' => 'edit']);
}
public function update(CreateProjectRequest $request, $project)
{
$this->project->fill($request->input())->save();
return redirect('project');
}
public function destroy($projectId)
{
$this->project->destroy($projectId);
return redirect('project');
}
}
答案 0 :(得分:2)
你应该试试......
$skuReplacement = implode(',', $skuReplacement);
您必须提供需要编辑的项目。