public function confirmUser($username, $token) { $user = User::where('username', '=', $username)->whereToken($token)->first(); $user->confirmed = 1; $user->token = null; $user->save(); return view('auth.confirmed_user', compact('user')); }
/** * Assign a task to a member * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function assignTask(Request $request) { $userId = (int) $request->user; $taskId = (int) $request->task; $user = User::find($userId); $task = Task::find($taskId); $updateTask = $task->update(['assigned_user' => $userId]); $job = (new assignedTaskToUserEmail($user, $task))->delay(60 * 2); $this->dispatch($job); return response()->json('Task assigned', 200); }
/** * 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); } }); }
/** * Add a new member to the board * Check if new user or existing user is invited * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function addMemberToBoard(Request $request) { $validator = Validator::make($request->all(), ['email' => 'required|email']); if ($validator->fails()) { return response()->json('Email is required and in the right format', 400); } $user = User::where('email', $request->email)->first(); $board = Board::where('identifier', $request->board)->first(); if (is_null($user)) { $member = Invite::create(['new_member' => $request->email, 'board_identifier' => $request->board]); //Queue invite email to new user $job = (new inviteNewUserToBoard($member))->delay(60 * 2); $this->dispatch($job); return response()->json('successfully invited new member', 200); } else { $member = Invite::create(['new_member' => $user->email, 'board_identifier' => $request->board]); //Queue invite to existing user $job = (new inviteExistingUserToBoard($member, $user))->delay(60 * 2); $this->dispatch($job); return response()->json('successfully invited new member', 200); } }
/** * Run the database seeds. * * @return void */ public function run() { factory(\Flisk\User::class, 5)->create(); User::create(['first_name' => 'Gareth', 'last_name' => 'Nicholson', 'gender' => 'm', 'confirmed' => 1, 'username' => 'Gareth', 'email' => '*****@*****.**', 'timezone' => 'Africa/Johannesburg', 'password' => bcrypt('password'), 'remember_token' => str_random(10)]); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'username' => $data['username'], 'gender' => $data['gender'], 'timezone' => $data['timezone'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
/** * 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'); } }