コード例 #1
0
 public function store(Request $request, Task $task)
 {
     $task->addNote(new Note($request->all()));
     $task->setUpdatedAt(Carbon::now()->toDateTimeString());
     $task->save();
     return back();
 }
コード例 #2
0
ファイル: TaskController.php プロジェクト: anhtt93/BookStore
 /**
  * Destroy the given task.
  *
  * @param  Request  $request
  * @param  Task  $task
  * @return Response
  */
 public function destroy(Request $request, Task $task)
 {
     if (\Auth::id() == $task->user_id) {
         $task->delete();
     }
     return redirect('/tasks');
 }
コード例 #3
0
 /**
  * checks each step of the path if it was completed (based on its timestamp).
  * also calls the findCrossingPath method to (surprise!) find the paths crossing the current path
  *
  * @param Task $task
  */
 public static function pathProgress(Task $task)
 {
     if ($task->path->isEmpty()) {
         $task->army->update(['task_id' => 0, 'path_id' => 0]);
         $task->delete();
         return;
     }
     $path = $task->path;
     self::processFoodConsumption($path);
     $finished = null;
     $path->filter(function ($item) use(&$finished) {
         if ($item->finished_at <= Carbon::now()) {
             // if the step is finished
             self::findCrossingPath($item);
             $finished = $item;
             $item->delete();
         }
     });
     // now $finished is the last element of the path.
     // $finished has the hex where the army is
     if ($finished != null) {
         $army = $task->army;
         $army->currentHex->update(['army_id' => 0]);
         $army->update(['current_hex_id' => $finished->hex_id]);
         $finished->hex->update(['army_id' => $army->id]);
     }
     if ($path->isEmpty()) {
         $task->army->update(['task_id' => 0, 'path_id' => 0]);
         $task->delete();
     }
 }
 /**
  * Create a new task` for the given user and data.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @param  array  $data
  * @return \App\Task
  */
 public function create($user, array $data)
 {
     $task = new Task($data);
     $task->user_id = $user->id;
     $task->save();
     return $task;
 }
コード例 #5
0
ファイル: TaskController.php プロジェクト: JCombee/dolphin
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $task = new Task();
     $task->name = $request->name;
     $task->user_id = $request->user_id;
     $task->save();
 }
コード例 #6
0
 public function getDelete(Task $task)
 {
     if ($task->user_id == Auth::user()->id) {
         //delete task als de juiste user is ingelogd
         $task->delete();
     }
     return Redirect::route('home');
 }
コード例 #7
0
 public function newtask(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:10']);
     $task = new Task();
     $task->name = $request->name;
     $task->save();
     return redirect('tasks');
 }
コード例 #8
0
ファイル: Task.php プロジェクト: rilonx/todo-api
 public static function createTask($input)
 {
     $task = new Task();
     $task->title = $input['title'];
     $task->complete = $input['complete'];
     $task->save();
     return $task;
 }
コード例 #9
0
ファイル: TaskRepository.php プロジェクト: ehomeuc/ehome
 public function save(Task $task, $members = null)
 {
     $task->save();
     /* Insert Task Members to Pivot Table */
     if ($members) {
         $task->syncMembers($members);
     }
     return true;
 }
コード例 #10
0
 function testSetLabelToTask()
 {
     $label = factory(\App\ProjectLabel::class)->make(['name' => "foo"]);
     $this->project->labels()->save($label);
     $this->task->label()->associate($label)->save();
     $this->assertEquals('foo', $this->task->label->name);
     $this->assertEquals(2, $this->task->activity->count());
     $this->assertEquals($label->id, $this->task->activity->get(1)->note);
 }
コード例 #11
0
 public function seedTasks($faker)
 {
     foreach (range(0, 100) as $number) {
         $task = new Task();
         $task->name = $faker->sentence;
         $task->done = $faker->boolean;
         $task->priority = $faker->randomDigit;
         $task->save();
     }
 }
コード例 #12
0
 /**
  * @param Faker $faker
  */
 private function seedTasks($faker)
 {
     foreach (range(0, 100) as $item) {
         $task = new Task();
         $task->name = $faker->sentence();
         $task->done = $faker->boolean();
         $task->priority = $faker->randomDigit();
         $task->save();
     }
 }
コード例 #13
0
 /**
  * Function for adding new user to database
  * @param Request $request [http request with data]
  * @return id [id of the task added]
  */
 public function add(Request $request)
 {
     if (Auth::check()) {
         $user_id = Auth::user()->id;
         $task = new Task();
         $task->task_name = $request->task_name;
         $task->user_id = $user_id;
         $task->save();
         return $task->id;
     }
 }
コード例 #14
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->validate($request, ['title' => 'required', 'description' => 'required']);
     $input = $request->all();
     $mTask = new Task();
     $task = $mTask->getTaskById($id);
     //        dd($task->toArray());
     $task->saveTask($id, $input);
     //        Session::flash('flash_message', 'Task successfully added!');
     return redirect()->back()->with('flash_message', 'Task successfully added!');
 }
コード例 #15
0
 /**
  * @param Task $task
  */
 public static function finishTask(Task $task)
 {
     switch ($task->type) {
         case 1:
             // create worker
             $task->building->city->human_resources->workers += 1;
             $task->building->city->human_resources->save();
             $task->delete();
             break;
         case 2:
             // create settler
             $task->building->city->human_resources->settlers += 1;
             $task->building->city->human_resources->save();
             $task->delete();
             break;
         case 3:
             // create a general
             if ($task->building->city->hex->army_id == 0) {
                 $army = Army::create(['user_id' => $task->building->city->owner, 'current_hex_id' => $task->building->city->hex->id]);
                 $task->building->city->hex->army_id = $army->id;
                 $task->building->city->hex->save();
             }
             if ($task->building->city->hex->army->general) {
                 break;
             }
             $task->building->city->hex->army->update(['general' => true]);
             $task->delete();
             break;
         case 11:
             // create unit
         // create unit
         case 12:
         case 13:
         case 14:
         case 15:
         case 16:
         case 17:
             if ($task->building->city->hex->army_id == 0) {
                 $army = Army::create(['user_id' => $task->building->city->owner, 'current_hex_id' => $task->building->city->hex->id]);
                 $task->building->city->hex->army_id = $army->id;
                 $task->building->city->hex->save();
             }
             $unit_type = 'unit' . ($task->type - 10);
             $task->building->city->hex->army->{$unit_type} += 1;
             $task->building->city->hex->army->save();
             $task->delete();
             break;
         case 20:
             // move army
             ArmyController::pathProgress($task);
             break;
     }
 }
コード例 #16
0
 public function post(Request $request)
 {
     //echo "post";
     $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
     if ($validator->fails()) {
         return redirect('/')->withInput()->withErrors($validator);
     }
     $task = new Task();
     $task->name = $request->name;
     $task->save();
     //print_r($request->name);
     return redirect('/');
 }
コード例 #17
0
ファイル: TaskController.php プロジェクト: phongln/laravel5
 public function update($taskID, TaskRequest $request)
 {
     $task = Task::findOrNew($taskID);
     $task->taskName = $request->taskName;
     $task->save();
     return view('edit', ['task' => $task]);
 }
コード例 #18
0
ファイル: TasksController.php プロジェクト: JuanVqz/crud5
 public function destroy($id)
 {
     $task = Task::findOrFail($id);
     $task->delete();
     \Session::flash('flash_message', 'Tarea borrada');
     return redirect()->route('tasks.index');
 }
コード例 #19
0
 public function destroy($id)
 {
     $response = Task::find($id)->delete();
     if ($response) {
         return redirect('/');
     }
 }
コード例 #20
0
ファイル: HomeController.php プロジェクト: leejunkit/vashti
 public function markComplete($taskId)
 {
     $task = Task::find($taskId);
     $task->completed = true;
     $task->save();
     return redirect()->route('tasks');
 }
コード例 #21
0
 public function store(Request $request, Task $listask)
 {
     //dd($listask);
     //dd($task);
     //dd("youpie");
     // Méthode de logout certifié :p
     /*
             Auth::logout();
             return redirect('/tasks');
             //*/
     //*
     $this->validate($request, ['task' => 'required|max:30', 'deadline' => 'required']);
     $listask->listasks()->create(['name' => $request->task, 'echeance' => $request->deadline]);
     return redirect("listasks/{$listask->id}");
     //*/
 }
コード例 #22
0
 function postTask(Request $request)
 {
     $task = $request->all();
     Task::create($task);
     $comm = Committee::where('id', $task['comm_id'])->first();
     $evnt = Event::where('id', $comm['event_id'])->first();
     //UPDATING WEIGHT OF COMMITTEE AND EVENT
     $comm->increment('weight', $task['weight']);
     $evnt->increment('weight', $task['weight']);
     //UPDATING PROGRESS OF COMMITTEE
     $progress = 0;
     $tasks = Task::where('comm_id', $comm->id)->get();
     foreach ($tasks as $task1) {
         $progress += $task1->weight * $task1->progress;
     }
     $progress = $progress / $comm->weight;
     $comm->progress = $progress;
     $comm->save();
     //UPDATING PROGRESS OF EVENT
     $progress2 = 0;
     $committees = Committee::all();
     foreach ($committees as $committee) {
         if ($committee->event_id == $evnt->id) {
             $progress2 += $committee->weight * $committee->progress;
         }
     }
     $progress2 = $progress2 / $evnt->weight;
     $evnt->progress = $progress2;
     $evnt->save();
     return redirect('profile');
 }
コード例 #23
0
ファイル: DisplayTasks.php プロジェクト: LakyLak/Projects
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $issues = Issue::with('company', 'company.person')->has('task', '<', 1)->get();
     foreach ($issues as $issue) {
         $task = new Task();
         $task->issue_id = $issue->id;
         $task->person_id = $issue->company->person->id;
         $task->priority = $issue->level * $issue->company->score;
         $task->save();
     }
     $tasks = Task::with('issue', 'issue.company', 'person')->orderBy('priority', 'DESC')->get();
     echo 'ID | Name | Company | Priority | Assigned Person', PHP_EOL;
     foreach ($tasks as $task) {
         echo sprintf('%d | %s | %s | %d | %s', $task->id, $task->issue->name, $task->issue->company->name, $task->priority, $task->person->name), PHP_EOL;
     }
 }
コード例 #24
0
 public function put($done, Task $task)
 {
     //echo $done."<br>";
     //var_dump($task);
     //echo "hallo";
     //var_dump($request-done);
     //echo $done ."<br>";
     //var_dump($task->id);
     //echo $task->id;
     //$task->done();
     //$task->done($done);
     //var_dump($task->done);
     //echo "hallo";
     //Task->done($task-id) = $request->name;
     //$numberOfDone = Task::findOrFail($task->id)->done(1);
     //$numberOfDone = Task::update(array('done' => 1));
     //echo $numberOfDone;
     //Task::findOrFail($task->id)->done->save();
     //var_dump($taskss);
     //var_dump(Task->done;
     //echo "hallo";
     /*
            $taskssss = Task::where('user_id', $request->user()->id)->get();
      foreach ($taskssss as $task){
          echo $task->done;
      }
     */
     //return redirect('/tasks');
     Task::where('id', $task->id)->update(['done' => $done]);
     return redirect('/tasks');
 }
コード例 #25
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 0; $i < 10; $i++) {
         $j = rand(0, 1000);
         Task::create(['author' => 'Testowy Autor ' . $j, 'name' => 'Testowe Zadanie ' . $j, 'category_id' => 1, 'user_id' => 1]);
     }
 }
コード例 #26
0
 public function tasks($id)
 {
     $line = Line::find($id);
     $tasksGroupedDate = Task::getGroupedDateByLineId($id);
     krsort($tasksGroupedDate);
     return view('line.tasks', ['line' => $line, 'tasksGroupedDate' => $tasksGroupedDate]);
 }
コード例 #27
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         Task::create(['user_id' => '1', 'title' => $faker->sentence(4), 'content' => $faker->paragraphs(8, true), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'due_at' => $faker->dateTimeBetween('+1 days', '+2 years')->format('m/d/Y')]);
     }
 }
コード例 #28
0
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $status = statu::orderBy('status', 'asc')->get();
     $owners = owner::orderBy('owner_name', 'asc')->get();
     $tasks = Task::orderBy('created_at', 'asc')->get();
     return view('home', compact('tasks'), compact('owners'));
 }
コード例 #29
0
 public function home()
 {
     $page_title = "لوحة التحكم";
     $section_title = "لوحة التحكم";
     Date::setLocale('ar');
     $date = Date::now()->format('j F Y');
     $day = Date::now()->format('l');
     $month = Date::now()->format('F');
     $year = Date::now()->format('Y');
     //**************Tasks***************
     $tasksToday = Task::orderBy('task_date', 'desc')->today()->take(5);
     $tasksWeek = Task::orderBy('task_date', 'desc')->thisweek()->take(5);
     $tasksMonth = Task::orderBy('task_date', 'desc')->thisMonth()->take(5);
     $tasks_count = count($tasksToday->toArray());
     //**************Fails***************
     $failsToday = Failure::orderBy('fail_time', 'desc')->today()->take(5);
     $failsWeek = Failure::orderBy('fail_time', 'desc')->thisweek()->take(5);
     $failsMonth = Failure::orderBy('fail_time', 'desc')->thisMonth()->take(5);
     $fails_count = count($failsToday->toArray());
     //**************Repairs***************
     $repairsToday = Repair::today();
     $repairsWeek = Repair::thisweek();
     $repairsMonth = Repair::thisMonth();
     $repairs_count = count($repairsToday->toArray());
     return view('dashboard.dashboard', compact('page_title', 'section_title', 'date', 'day', 'month', 'year', 'tasksToday', 'tasksMonth', 'tasksWeek', 'tasks_count', 'failsToday', 'failsMonth', 'failsWeek', 'fails_count', 'repairsToday', 'repairsMonth', 'repairsWeek', 'repairs_count'));
 }
コード例 #30
0
 /**
  * post的方式添加一条记录
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $request_url = str_replace("http://" . Config::get('app.url'), "", $request->url());
     //验证参数
     $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
     //验证参数完整性
     if ($validator->fails()) {
         $error = $validator->errors()->all();
         //写入日志
         Log::error(['error' => $error, 'request' => $request->all(), 'header' => $request->headers, 'client_ip' => $request->getClientIp()]);
         //返回错误信息
         return Error::returnError($request_url, 1001);
     }
     //验证token
     //        $user_id=Common::validateToken($request->get('token'));
     //
     //        if($user_id == false){
     //            return Error::returnError($request_url,2002);
     //        }
     $name = $request->get('name');
     //写入操作
     $add = Task::addTask($name);
     $info = Task::getTaskInfo($add);
     //返回对应的结果
     $json_arr = ['request' => $request_url, 'ret' => $info];
     return Common::returnResult($json_arr);
 }