Пример #1
0
 public function tasklists()
 {
     $user = JWTAuth::parseToken()->authenticate();
     $tasklist_ids = $user->tasks->lists('task_list_id');
     $tasklists = TaskList::whereIn('id', $tasklist_ids)->get();
     return $tasklists;
 }
Пример #2
0
 public function upload(Request $request)
 {
     // loop through files and move the chunks to a temporarily created directory
     if (!empty($_FILES)) {
         foreach ($_FILES as $file) {
             // check the error status
             if ($file['error'] != 0) {
                 $this->_log('error ' . $file['error'] . ' in file ' . $_POST['flowFilename']);
                 continue;
             }
             // init the destination file (format <filename.ext>.part<#chunk>
             // the file is stored in a temporary directory
             $temp_dir = public_path() . '/temp/' . $_POST['flowIdentifier'];
             $dest_file = $temp_dir . '/' . $_POST['flowFilename'] . '.part' . $_POST['flowChunkNumber'];
             // create the temporary directory
             if (!is_dir($temp_dir)) {
                 mkdir($temp_dir, 0777, true);
             }
             // move the temporary file
             if (!move_uploaded_file($file['tmp_name'], $dest_file)) {
                 $this->_log('Error saving (move_uploaded_file) chunk ' . $_POST['flowChunkNumber'] . ' for file ' . $_POST['flowFilename']);
             } else {
                 // check if all the parts present, and create the final destination file
                 $this->createFileFromChunks($temp_dir, $_POST['flowFilename'], $_POST['flowChunkSize'], $_POST['flowTotalSize']);
                 if ($request->input('mode') == "register") {
                     $user = User::find($request->input('id'));
                     $user->pictureDist = 'temp/' . $_POST['flowFilename'];
                     $user->update();
                 } else {
                     if ($request->input('mode') == "activity") {
                         $activity = Activity::find($request->input('id'));
                         $activity->pictureDist = 'temp/' . $_POST['flowFilename'];
                         $activity->update();
                     } else {
                         if ($request->input('mode') == "task") {
                             $activity = TaskList::find($request->input('id'));
                             $activity->pictureLocation = 'temp/' . $_POST['flowFilename'];
                             $activity->update();
                         }
                     }
                 }
             }
         }
     }
     ////////////////////////////////////////////////////////////////////
     // THE SCRIPT
     ////////////////////////////////////////////////////////////////////
     //check if request is GET and the requested chunk exists or not. this makes testChunks work
     if ($_SERVER['REQUEST_METHOD'] === 'GET') {
         $temp_dir = 'temp/' . $_GET['flowIdentifier'];
         $chunk_file = $temp_dir . '/' . $_GET['flowFilename'] . '.part' . $_GET['flowChunkNumber'];
         if (file_exists($chunk_file)) {
             header("HTTP/1.0 200 Ok");
         } else {
             header("HTTP/1.0 404 Not Found");
         }
     }
 }
Пример #3
0
 public function testDestroy()
 {
     $taskID = \App\TaskList::where("plant_id", "=", \App\Plant::where("name", "=", "TestActivityPlant")->first()->id)->where("time", "=", "16:00:00")->first()->id;
     $Task3 = array("id" => $taskID, "description" => "TestTask", "date" => "2015-12-06", "time" => "16:00:00", "plant_id" => \App\Plant::where("name", "=", "TestActivityPlant")->first()->id, "user_id" => 66);
     $this->action('DELETE', 'TaskListController@destroy', array("id" => $taskID));
     $this->notSeeInDatabase("tasklist", $Task3);
     $this->action('DElETE', 'TaskListController@destroy', null);
     $this->assertResponseStatus(405);
 }
Пример #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \App\TaskList  $task_list
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, TaskList $task_list)
 {
     $task = $task_list->addTask($request->description);
     return response()->json(compact('task'));
 }
Пример #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if ($id == null) {
         return response("fail", 500);
     }
     $taskList = TaskList::find($id);
     $taskList->activityType()->detach();
     $taskList->workerMember()->detach();
     $taskList->delete();
     return response("success", 200);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  \App\TaskList  $task_list
  * @return \Illuminate\Http\Response
  */
 public function destroy(TaskList $task_list)
 {
     $task_list->delete();
     return response(null, 204);
 }