本文整理汇总了PHP中app\Project::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::fill方法的具体用法?PHP Project::fill怎么用?PHP Project::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Project
的用法示例。
在下文中一共展示了Project::fill方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param App\Http\Request\Request
* @param App\Project $project
* @return Response
*/
public function update(Request $request, Project $project)
{
$this->validate($request, ['nama_project' => 'required', 'nama_lembaga' => 'required', 'tanggal_mulai' => 'required|date', 'tanggal_selesai' => 'required|date|after:' . $request->input('tanggal_mulai'), 'alamat' => 'required']);
$input = $request->all();
$project->fill($input)->save();
return redirect('/project')->with('success', 'Sukses memperbarui proyek ' . $input['nama_project'] . '.');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$validator = $this->validateName();
if ($validator->fails()) {
return $validator->errors()->all();
}
$instance = new Project();
$instance->fill($request->all());
return Auth::user()->projects()->save($instance);
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param ProjectRequest $request
* @param Project $project
* @return Response
*/
public function update(ProjectRequest $request, Project $project)
{
$data = $request->all();
$data['images'] = $project->images ? $project->images : [];
$i = 0;
$files = json_decode($data['files_deleted']);
foreach ($files as $file) {
if (($key = array_search($file, $data['images'])) !== false) {
unset($data['images'][$key]);
$this->delete($file);
}
}
foreach ($_FILES['images']['tmp_name'] as $tmpPath) {
if (!empty($tmpPath)) {
$fileUpload = $this->upload($tmpPath, $i++);
array_push($data['images'], $fileUpload);
}
}
// Hàm unset() khiến key của array ko còn là dãy số liên tiếp
// Lúc này Laravel sẽ ko đối xử và lưu 'images' như kiểu array mà là kiểu Json, cần sửa chữa vấn đề này
$data['images'] = array_values($data['images']);
$project->fill($data)->save();
return redirect('m/danh-sach-nha-dat/du-an')->with('flash_message', Lang::get('system.update'));
}
示例4: SaveProject
public function SaveProject(Request $request)
{
$project = new Project();
$project->fill($request->except('_token', 'submitBtn'));
$project->save();
$member = Member::find($request->get('member_id'));
if ($request->get('submitBtn') == 'save') {
return redirect()->route('thank.you');
}
return back()->withMember($member)->withMessage('project saved');
}