Beispiel #1
0
 public function postFileS3($event, $task)
 {
     // defs
     $user = Auth::user();
     $all_input = Input::all();
     eerror_log('AI ' . $all_input['path'] . ' - ' . $event->id . ' - ' . $task->id);
     // create a new TaskFile
     $taskfile = new TaskFile();
     // stash posted data
     $taskfile->original_filename = $all_input['original_name'];
     $taskfile->taskevents_id = $task->id;
     $taskfile->path = $all_input['path'];
     if ($user) {
         $taskfile->users_id = $user->id;
     }
     // save
     $taskfile->save();
     // set num files depending on user id
     if ($task->updated_by !== $user->id) {
         // reset
         $task->updated_by = $user->id;
         $task->cnt_updated_files = 1;
         $task->cnt_updated_comments = 0;
         $task->owner_changed_at = date("Y-m-d H:i:s");
     } else {
         $num_updated_fles = TaskFile::where('taskevents_id', $task->id)->where('users_id', $user->id)->where('updated_at', '>', $task->owner_changed_at)->count();
         $task->cnt_updated_files = $num_updated_fles ?: 1;
     }
     $task->update();
     $response = Response::make('File Uploaded and moved to destination :)' . json_encode($task), 200);
     return $response;
 }