示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $board = \Flisk\Board::find(1);
     $board2 = \Flisk\Board::find(2);
     factory(\Flisk\Task::class, 10)->create(['board_identifier' => $board->identifier, 'user_id' => 6]);
     factory(\Flisk\Task::class, 10)->create(['board_identifier' => $board2->identifier, 'user_id' => 1]);
 }
示例#2
0
 /**
  * Decline an invite to join a board
  *
  * @param $board
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function declineInvite($board)
 {
     $user = auth()->user();
     $board = Board::where('identifier', $board)->first();
     $decline = Invite::where('board_identifier', $board->identifier)->where('new_member', $user->email)->delete();
     return redirect('/boards');
 }
示例#3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(\Flisk\Board::class, 2)->create();
     $user = \Flisk\User::find(6);
     $user2 = \Flisk\User::find(5);
     $board = \Flisk\Board::find(1);
     $board->users()->attach($user, ['owner' => $user->id, 'active' => true]);
     $board->users()->attach($user2, ['active' => true]);
     $user3 = \Flisk\User::find(1);
     $user4 = \Flisk\User::find(2);
     $board = \Flisk\Board::find(2);
     $board->users()->attach($user3, ['owner' => $user3->id, 'active' => true]);
     $board->users()->attach($user4, ['active' => false]);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Queue::failing(function (JobFailed $event) {
         Log::error('Error with Queue');
     });
     User::creating(function ($user) {
         return $user->token = str_random(12);
     });
     Board::creating(function ($board) {
         try {
             $uuid = Uuid::uuid1()->toString();
             $board->identifier = $uuid;
         } catch (UnsatisfiedDependencyException $e) {
             Log::error('UUID creation error => ' . $e);
             return response()->json('Error creating board', 500);
         }
     });
 }
示例#5
0
 /**
  * Get all tasks in json
  * Used in vue - /tasks/all_json
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function getTasksJson(Request $request)
 {
     $tasks = Task::where('board_identifier', $request->board)->whereDone(0)->orderBy('created_at', 'desc')->get();
     $board = Board::where('identifier', $request->board)->first();
     $userCount = $board->users()->get()->count();
     if (is_null($tasks)) {
         return redirect('/boards');
     }
     foreach ($tasks as $task) {
         if (!is_null($task->assigned_user)) {
             $task->assignee = User::where('id', $task->assigned_user)->first();
         } else {
             $task->assignee = [];
         }
         $task->created_when = $task->created_at->diffForHumans();
         $task->user_count = $userCount;
     }
     return response()->json($tasks, 200);
 }
示例#6
0
 /**
  * Get all board members as json
  * Used in vue - /members
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function getBoardMembers(Request $request)
 {
     $board = Board::where('identifier', $request->board)->first();
     $boardUsers = $board->users()->where('active', true)->get();
     return response()->json($boardUsers);
 }
示例#7
0
 /**
  * Show deleted tasks
  *
  * @param $identifier
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
  */
 public function deletedTasks($identifier)
 {
     $user = auth()->user();
     $board = Board::where('identifier', $identifier)->first();
     $tasks = Task::where('board_identifier', $identifier)->onlyTrashed()->orderBy('deleted_at', 'desc')->paginate(10);
     foreach ($tasks as $task) {
         $user = User::find($task->user_id);
         $task->createdBy = $user->first_name . ' ' . $user->last_name;
     }
     if (Gate::allows('isOwner', $board)) {
         return view('reports.deleted_tasks', compact('board', 'tasks', 'user'));
     } else {
         return redirect('/boards');
     }
 }