私はlaravel 5.2でプロジェクト管理ツールを開発しています。私のアプリケーションでは、ユーザーはプロジェクトを作成でき、1つのプロジェクトには多くのタスクがあり、1つのタスクには多くのファイルが添付されています。私はMyファイルを保存するためにcloudderを使用しています。現在、私のプロジェクトファイルは関連するプロジェクトにのみ割り当てられています。今、関連するプロジェクトの各タスクにファイルを表示する必要があります。App Http Controllers Fileslersroller :: uploadAttachments()の引数3がありません。
FileController
class FilesController extends Controller
{
public function uploadAttachments(Request $request, $id,$taskId) //this is line 20
{
$this->validate($request, [
'file_name' => 'required|mimes:jpeg,bmp,png,pdf|between:1,7000',
]);
$filename = $request->file('file_name')->getRealPath();
Cloudder::upload($filename, null);
list($width, $height) = getimagesize($filename);
$fileUrl = Cloudder::show(Cloudder::getPublicId(), ["width" => $width, "height" => $height]);
$this->saveUploads($request, $fileUrl, $id,$taskId);
return redirect()->back()->with('info', 'Your Attachment has been uploaded Successfully');
}
private function saveUploads(Request $request, $fileUrl, $id,$taskId)
{
$file = new File;
$file->file_name = $request->file('file_name')->getClientOriginalName();
$file->file_url = $fileUrl;
$file->project_id = $id;
$file->task_id = $taskId;
$file->save();
}
return redirect()->route('projects.show')->with('info', 'File deleted successfully');
}
}
ルート
Route::post('projects/{projects}/files', [
'uses' => '[email protected]',
'as' => 'projects.files',
'middleware' => ['auth']
]);
とファイル形式
<div class="row" style="border:1px solid #ccc;margin-left:5px;width:100%;padding:15px;">
@foreach($project->files as $file)
<div>
<div><i class="fa fa-check-square-o"></i>
<span>
<a href="{{ $file->file_url }}" target="_blank">{{ $file->file_name }}</a>
</span>
</div>
</div>
<hr/>
@endforeach
<form class="form-vertical" role="form"
enctype="multipart/form-data"
method="post"
action="{{ route('projects.files', ['projectId'=> $project->id, 'taskId'=>$task->id])}}">
<div class="form-group{{ $errors->has('file_name') ? ' has-error' : '' }}">
<input type="file" name="file_name" class="form-control" id="file_name">
@if ($errors->has('file_name'))
<span class="help-block">{{ $errors->first('file_name') }}</span>
@endif
</div>
<div class="form-group">
<button type="submit" class="btn btn-info">Add Files</button>
</div>
form.blade.phpファイルは/今、私はこのエラーを得ている:
ErrorException in FilesController.php line 20: Missing argument 3 for App\Http\Controllers\FilesController::uploadAttachments()
どうすればこの問題を解決できますか?
私はこの問題を解決するための – John
ありません任意のアイデア.....ここにいくつかの助けが必要です??? ... – John
あなたがこの問題を解決するための任意のアイデアを持っていますか? – John