public function index()
 {
     $userid = Auth::user()->id;
     $todos = Todo::where('user_id', '=', $userid)->get();
     $todosDone = DB::table('todos')->where([['user_id', '=', $userid], ['isDone', '=', 'true']])->get();
     return view('todos.index')->with(['todos' => $todos, 'todosDone' => $todosDone]);
 }
 public function forUser(User $user)
 {
     // return Todo::where('user_id', $user->id)
     //             ->orderBy('created_at', 'asc')
     //             ->get();
     return Todo::where('user_id', $user->id)->orderBy('completed', 'asc')->orderBy('created_at', 'asc')->paginate(10);
 }
 public function search(Request $request)
 {
     $keywords = $request->get('keywords');
     $result = Todo::where('title', 'LIKE', '%' . $keywords . '%')->get();
     //$result = Todo::like('title',$keywords)->get();
     return view('todo.search')->with('todos', $result);
 }
Exemple #4
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     if ($this->isUpdateRequest() or $this->isDeleteRequest()) {
         $id = $this->route('todo');
         return Todo::where('id', $id)->where('user_id', $this->user()->id)->exists();
     }
     return true;
 }
 public function deleteCompleted()
 {
     $todos = Todo::where('done', true)->get();
     foreach ($todos as $todo) {
         $todo->delete();
     }
     Event::fire(new TodoGetAllBack(Todo::where('done', false)->get(['id', 'text', 'done'])));
 }
 public function destroy($id)
 {
     $user = JWTAuth::parseToken()->authenticate();
     $todo = Todo::where('owner_id', $user->id)->where('id', $id)->first();
     if ($todo) {
         Todo::destroy($todo->id);
         return response('Success', 200);
     } else {
         return response('Unauthoraized', 403);
     }
 }
Exemple #7
0
 public function update(Request $request)
 {
     $inputs = $request->all();
     $task = App\Task::where('title', $inputs['title'])->first();
     // create task if the there is no task with that title
     if (null == $task) {
         $task = App\Task::create(['title' => $inputs['title'], 'carry_over' => 1]);
     }
     if ($inputs['task_id'] != $task->id) {
         $inputs['task_id'] = $task->id;
     }
     return Todo::where('id', $inputs['id'])->update($inputs);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //dd(Auth::user());
     $todos = Todo::where('user_id', '=', Auth::user()->id)->get();
     return $todos;
 }
 public function index(Request $request)
 {
     $start_date = $request->input('start_date') ?: date('Y-m-d', strtotime('-30 days'));
     $end_date = $request->input('end_date') ?: date('Y-m-d', strtotime(date('Y-m-d')));
     if (Entrust::hasRole('user')) {
         return redirect('/')->withErrors(config('constants.NA'));
     }
     $user_count = \App\User::with('roles')->whereHas('roles', function ($query) {
         $query->whereName('user');
     })->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $staff_count = \App\User::with('roles')->whereHas('roles', function ($query) {
         $query->where('name', '!=', 'user');
     })->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $ticket_count = \App\Ticket::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $closed_ticket_count = \App\Ticket::where('ticket_status', '=', 'close')->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
     $closed_ticket_percentage = $ticket_count > 0 ? round($closed_ticket_count / $ticket_count * 100, 2) : 0;
     $ticket_status_stats = \App\Ticket::select('ticket_status', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('ticket_status')->get();
     $status_stats = array();
     foreach ($ticket_status_stats as $stat) {
         $status_stats[] = array('label' => Helper::toWord($stat->ticket_status), 'value' => $stat->total);
     }
     $ticket_priority_stats = \App\Ticket::select('ticket_priority', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('ticket_priority')->get();
     $priority_stats = array();
     foreach ($ticket_priority_stats as $stat) {
         $priority_stats[] = array('label' => Helper::toWord($stat->ticket_priority), 'value' => $stat->total);
     }
     $ticket_type_status = \App\Ticket::select('ticket_type_id', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('ticket_type_id')->get();
     $type_stats = array();
     foreach ($ticket_type_status as $stat) {
         $type_stats[] = array('label' => Helper::toWord($stat->TicketType->ticket_type_name), 'value' => $stat->total);
     }
     $ticket_department_stats = \App\Ticket::select('department_id', DB::raw('count(*) as total'))->where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->groupBy('department_id')->get();
     $department_stats = array();
     foreach ($ticket_department_stats as $stat) {
         $department_stats[] = array('label' => Helper::toWord($stat->Department->department_name), 'value' => $stat->total);
     }
     $users = \App\User::with('roles')->whereHas('roles', function ($query) {
         $query->where('name', '!=', 'user');
     })->where('id', '!=', Auth::user()->id)->get();
     $user_list = array();
     foreach ($users as $user) {
         $user_list[$user->id] = $user->name . ' (Department : ' . $user->Profile->Department->department_name . ')';
     }
     $query = DB::table('activity_log')->join('users', 'users.id', '=', 'activity_log.user_id')->select(DB::raw('name,activity_log.created_at AS created_at,text,user_id'));
     if (!Entrust::hasRole('admin')) {
         $query->where('user_id', '=', Auth::user()->id);
     }
     $activities = $query->latest()->limit(100)->get();
     $holidays = \App\Holiday::all();
     $todos = \App\Todo::where('user_id', '=', Auth::user()->id)->orWhere(function ($query) {
         $query->where('user_id', '!=', Auth::user()->id)->where('visibility', '=', 'public');
     })->get();
     $events = array();
     foreach ($holidays as $holiday) {
         $start = $holiday->date;
         $title = 'Holiday: ' . $holiday->holiday_description;
         $color = '#1e5400';
         $events[] = array('title' => $title, 'start' => $start, 'color' => $color);
     }
     foreach ($todos as $todo) {
         $start = $todo->date;
         $title = 'To do: ' . $todo->todo_title . ' ' . $todo->todo_description;
         $color = '#ff0000';
         $url = '/todo/' . $todo->id . '/edit';
         $events[] = array('title' => $title, 'start' => $start, 'color' => $color, 'url' => $url);
     }
     $colors = ['#5CB85C', '#FFD600', '#D10D0D', '#1A89E8', '#458b00', '#f85931', '#ce1836', '#009989', '#00688b', '#8b1a1a'];
     shuffle($colors);
     $status_colors = $colors;
     shuffle($colors);
     $priority_colors = $colors;
     shuffle($colors);
     $type_colors = $colors;
     shuffle($colors);
     $department_colors = $colors;
     $assets = ['calendar', 'graph'];
     return view('dashboard', compact('user_count', 'staff_count', 'assets', 'activities', 'user_list', 'holidays', 'events', 'ticket_count', 'closed_ticket_percentage', 'status_stats', 'priority_stats', 'type_stats', 'department_stats', 'status_colors', 'priority_colors', 'type_colors', 'department_colors', 'start_date', 'end_date'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Todo::where('user_id', Auth::user()->id)->get();
 }
 /**
  * View ToDos listing
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $todoList = Todo::where('user_id', Auth::user()->id)->paginate(7);
     return view('todo.list', compact('todoList'));
 }
 public function index()
 {
     $todo = Todo::where("done", "!=", "1")->get();
     $done = Todo::where("done", "=", "1")->get();
     return view("index", compact("todo", "done"));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(TodoRequest $request, $id)
 {
     Todo::where('id', $id)->update(['name' => $request->input('name'), 'description' => $request->input('description'), 'completed' => $request->input('completed')]);
     return redirect()->route('index');
 }
 private function calculateProjectEstimates($project)
 {
     $todos = Todo::where("project_id", '=', $project->todoist_id)->orderBy('priority', 'desc')->get();
     $estimated_time = 0;
     foreach ($todos as $todo) {
         $estimated_time += $todo->estimated_time;
     }
     $project->estimated_time = $estimated_time;
     $estimated_time = $estimated_time / 8;
     $now = date("Y-m-d");
     $project->due_date = date('Y-m-d', strtotime(sprintf("+%d days", $estimated_time)));
     $project->save();
 }
Exemple #15
0
    Route::get('/', 'Auth\\AuthController@getLogin');
    // Authentication routes...
    Route::get('auth/login', 'Auth\\AuthController@getLogin');
    Route::post('auth/login', 'Auth\\AuthController@postLogin');
    // Registration routes...
    Route::get('auth/register', 'Auth\\AuthController@getRegister');
    Route::post('auth/register', 'Auth\\AuthController@postRegister');
});
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Route::group(['middleware' => 'auth'], function () {
    Route::get('goal/create', 'GoalController@create');
    Route::post('goal/store', 'GoalController@store');
    Route::get('goal/{id}', ['uses' => 'GoalController@show', 'as' => 'showGoal']);
    Route::post('logs/store', function (Request $request) {
        $log = Log::create($request->all());
        return $log;
    });
    Route::get('/api/goal/{goal_id}/logs/', function ($goal_id) {
        return Log::where('goal_id', $goal_id)->orderBy('id', 'DESC')->get();
    });
    Route::post('todo/store', function (Request $request) {
        $todo = Todo::create($request->all());
        return $todo;
    });
    Route::get('/api/goal/{goal_id}/todos/', function ($goal_id) {
        return Todo::where('goal_id', $goal_id)->orderBy('id', 'DESC')->get();
    });
    Route::post('todo/update/{todo_id}', function (Request $request, $todo_id) {
        Todo::find($todo_id)->update(['done' => $request->input('done')]);
    });
});
Exemple #16
0
 public function removeDoneTasks(Todo $todos)
 {
     $todos->where('done', 1)->delete();
     return redirect()->route('admin.todos.index')->withWarning("All tasks marked as done have been removed!");
 }
 private function updateTodoList()
 {
     foreach ($this->todos as $todo) {
         $cr_todo = Todo::where('todoist_id', $todo->id)->first();
         if (!$cr_todo) {
             $cr_todo = new todo();
         }
         if (isset($todo->id)) {
             $cr_todo->todoist_id = $todo->id;
         }
         if (isset($todo->user_id)) {
             $cr_todo->user_id = $todo->user_id;
         }
         if (isset($todo->content)) {
             $cr_todo->content = $todo->content;
         }
         if (isset($todo->due_date)) {
             $cr_todo->due_date = $todo->due_date;
         }
         if (isset($todo->day_order)) {
             $cr_todo->day_order = $todo->day_order;
         }
         if (isset($todo->assigned_by_uid)) {
             $cr_todo->assigned_by_uid = $todo->assigned_by_uid;
         }
         if (isset($todo->sync_id)) {
             $cr_todo->sync_id = $todo->sync_id;
         }
         if (isset($todo->in_history)) {
             $cr_todo->in_history = $todo->in_history;
         }
         if (isset($todo->date_added)) {
             $cr_todo->date_added = $todo->date_added;
         }
         if (isset($todo->checked)) {
             $cr_todo->checked = $todo->checked;
         }
         if (isset($todo->date_lang)) {
             $cr_todo->date_lang = $todo->date_lang;
         }
         if (isset($todo->indent)) {
             $cr_todo->indent = $todo->indent;
         }
         if (isset($todo->is_deleted)) {
             $cr_todo->is_deleted = $todo->is_deleted;
         }
         if (isset($todo->priority)) {
             $cr_todo->priority = $todo->priority;
         }
         if (isset($todo->responsible_uid)) {
             $cr_todo->responsible_uid = $todo->responsible_uid;
         }
         if (isset($todo->project_id)) {
             $cr_todo->project_id = $todo->project_id;
         }
         if (isset($todo->collapsed)) {
             $cr_todo->collapsed = $todo->collapsed;
         }
         //$cr_todo->date_string = $todo->date_string ;
         if (isset($todo->is_archived)) {
             $cr_todo->is_archived = $todo->is_archived;
         }
         if (isset($todo->item_order)) {
             $cr_todo->item_order = $todo->item_order;
         }
         //$cr_todo->due_date_utc = $todo->due_date_utc ;
         if (isset($todo->date_checked)) {
             $cr_todo->date_checked = $todo->date_checked;
         }
         $cr_todo->touch();
         if (isset($cr_todo->is_deleted)) {
             if (!$cr_todo->is_deleted) {
                 $cr_todo->save();
             } else {
                 $cr_todo->delete();
             }
         }
         if (isset($todo->labels)) {
             foreach ($todo->labels as $label) {
                 $label = Label::where('todoist_id', $label)->first();
                 $cr_todo->labels()->attach($label->id);
             }
         }
     }
 }