/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if ($request->input('plant_id') == null) {
         return response()->json("invalid", "500");
     }
     $user = User::where('username', '=', $request->input('username'))->first();
     $task = new TaskList();
     $task->description = $request->input('description');
     $task->date = date("Y-m-d", strtotime($request->input('date')));
     $task->time = $request->input('time');
     $task->status = "Remaining";
     $task->user_id = $user->id;
     $task->plant_id = $request->input('plant_id');
     $typeActivity[] = $request->input('type');
     $task->save();
     $worker = $request->input('worker');
     foreach ($worker as $uid) {
         if ($uid != "0") {
             $notificationControl = new notificationController();
             $task->workerMember()->attach($uid);
             $detailPlantPlot = Plant::where("id", "=", $task->plant_id)->with("plot")->first();
             $message = "" . $user->name . " " . $user->surname . "has assigned you a task!";
             $notificationControl->sentTaskToFarmWorker($message, $uid);
         }
     }
     foreach ($typeActivity as $id) {
         if ($id != "0") {
             $task->activityType()->attach($id);
         }
     }
     return $task;
     //
 }
 public function testDestroyPlant()
 {
     $id = \App\Plant::where("name", "like", "Test plant")->first()->id;
     $plantController = new \App\Http\Controllers\plantController();
     $plantController->destroy($id);
     $this->assertNull($plantController->show($id));
     $this->assertNull($plantController->destroy(null));
 }
 public function testDestroy()
 {
     $Activity3 = array("description" => "Test store activity updated", "date" => "2015-10-5", "time" => "23:00:00", "plant_id" => \App\Plant::where("name", "=", "TestActivityPlant")->first()->id, "weather" => "fews cloud");
     $ActivityController = new \App\Http\Controllers\activityController();
     $ActivityController->destroy(activity::where("description", "=", "Test store activity updated")->first()->id);
     $this->notSeeInDatabase("activity", $Activity3);
     $this->assertNull($ActivityController->destroy(null));
 }
 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);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $plant = Plant::where('plot_id', 'like', $id)->get();
     return $plant;
     ////
 }