I am developing project management app in Laravel 5.2. in My application I have one project many tasks and one task have many file attachments. this is My file attachment view file
@foreach($task->files as $file) //line 14
<div>
<div><i class="fa fa-check-square-o"></i>
<span>
<a href="" target="_blank"></a>
</span>
</div>
</div>
and My FileController is this
use Cloudder;
use App\File as File;
use App\Task;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class FilesController extends Controller
{
public function uploadAttachments(Request $request,$id,$taskId)
{
$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);
and route is this
Route::post('projects/{projects}/tasks/{tasks}/', [
'uses' => 'FilesController@uploadAttachments',
'as' => 'projects.files',
'middleware' => ['auth']
]);
but got this error
ErrorException in ae0a86ab95cb7f092eb44a17fd000e94f21b305d.php line 14:
Undefined variable: task (View: C:\Users\13\Desktop\acxian\resources\views\files\form.blade.php)
how can fix this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire