Пример #1
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;
     }
 }
Пример #2
0
 /**
  * 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();
     }
 }
 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');
 }
 public function delete(Task $task)
 {
     $task->delete();
     return redirect('/');
     //print_r($task);
 }
Пример #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Task $task, TaskRequest $request)
 {
     Log::info("[App\\TaskController]: Delete a Task");
     $task->delete();
     return response()->json(array('success' => true));
 }
Пример #7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Project $project, Task $task)
 {
     $task->delete();
     return Redirect::route('projects.tasks.index', array($project->id, $task->id))->with('message', 'Tarefa deletada!');
 }
Пример #8
0
 /**
  * Destroy the given task.
  *
  * @param  Request $request
  * @param  Task $task
  * @return Response
  */
 public function destroy(Request $request, Task $task)
 {
     $task->delete();
     return redirect('/tasks');
 }
Пример #9
0
 public function destroy(Task $task)
 {
     $task->delete();
     return response()->json(['message' => 'Tarea borrada exitosamente.']);
 }
Пример #10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Project $project, Task $task)
 {
     $task->delete();
     return Redirect::route('projects.open', $project->slug)->with('message', 'Task deleted.');
 }
Пример #11
0
 /**
  * Remove the specified resource from storage
  * @param Project $project
  * @param Task $task
  */
 public function destroy(Project $project, Task $task, Request $request)
 {
     $this->validate($request, $this->rules);
     $task->delete();
     return Redirect::route('projects.show', $project->slug)->with('message', 'Task Deleted');
 }
 public function destroy(Category $category, Task $task)
 {
     $task->delete();
     return Redirect::route('categories.show', $category->slug)->with('message', 'Task deleted.');
 }
Пример #13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Project $project, Task $task)
 {
     //return view('tasks/index',compact('project'));
     $task->delete();
     return Redirect::route('projects.show', $project->slug)->with('message', 'Task deleted.');
 }
 public function destroy(Request $request, Task $task)
 {
     //$this->authorize('destroy', $task);
     $task->delete();
     return redirect('/tasks');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  \App\Project $project
  * @param  \App\Task    $task
  * @return Response
  */
 public function destroy(Project $project, Task $task)
 {
     //
     $task->delete();
     return Redirect::route('projects.show', $project->slug)->with('message', 'Success: Your Task deleted.');
 }
Пример #16
0
 /**
  * Delete the given Driver.
  *
  * @param  Task $task
  */
 public function delete(Task $task)
 {
     $task->delete();
 }
Пример #17
0
 /**
  * Remove the specified resource from storage.
  * 
  * @param Project $project
  * @param Task $task
  */
 public function destroy(Project $project, Task $task)
 {
     $task->delete();
     return $task;
 }
 /**
  * To Delete A Task
  */
 public function deleteTask(Task $task)
 {
     $task->delete();
     return redirect('/');
 }
Пример #19
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Project $project, Task $task, Request $request)
 {
     $task->delete();
     return Redirect::route('projects.show', [$project->slug])->with('message', 'Task deleted.');
 }
Пример #20
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Project $project, Task $task)
 {
     $task->delete();
     return Redirect::route('projects.show', $project->slug)->with('message', 'Tâche supprimée');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param Task $task
  * @return Response
  * @throws \Exception
  */
 public function destroy(Task $task)
 {
     $task->delete();
     return redirect()->route('tasks.index');
 }
Пример #22
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \App\TaskList  $task_list
  * @param  \App\Task  $task
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, TaskList $task_list, Task $task)
 {
     $task->delete();
     return response(null, 204);
 }
Пример #23
0
use App\Task;
use Illuminate\Http\Request;
Route::group(['middleware' => ['web']], function () {
    /**
     * Show Task Dashboard
     */
    Route::get('/', function () {
        $tasks = Task::orderBy('created_at', 'asc')->get();
        return view('tasks', ['tasks' => $tasks]);
    });
    /**
     * Add New Task
     */
    Route::post('/task', function (Request $request) {
        $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();
        return redirect('/');
    });
    /**
     * Delete Task
     */
    Route::delete('/task/{task}', function (Task $task) {
        $task->delete();
        return redirect('/');
    });
});
 public function destroy(Task $task)
 {
     // echo "Hello to destroy";
     $task->delete();
     return redirect('/');
 }