diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 763952d5..0d6bb954 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -4,6 +4,8 @@ use Auth; use Emoji; +use Notifynder; +use App\Models\User; use App\Models\Team; use App\Models\Wiki; use App\Models\Page; @@ -11,21 +13,58 @@ use App\Models\Comment; use Illuminate\Http\Request; +/** + * Class CommentController + * + * @package App\Http\Controllers + * @author Zeeshan Ahmed + */ class CommentController extends Controller { + /** + * @var \Illuminate\Http\Request + */ protected $request; - protected $comment; - + /** + * @var \App\Models\Page + */ protected $page; - public function __construct(Request $request, Page $page, Comment $comment) + /** + * @var \App\Models\Comment + */ + protected $comment; + + /** + * @var \App\Models\User + */ + protected $user; + + /** + * CommentController constructor. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Page $page + * @param \App\Models\Comment $comment + * @param \App\Models\User $user + */ + public function __construct(Request $request, Page $page, Comment $comment, User $user) { + $this->page = $page; + $this->user = $user; $this->request = $request; $this->comment = $comment; - $this->page = $page; } + /** + * Create a new wiki comment. + * + * @param \App\Models\Team $team + * @param \App\Models\Space $space + * @param \App\Models\Wiki $wiki + * @return \Illuminate\Http\RedirectResponse + */ public function storeWikiComment(Team $team, Space $space, Wiki $wiki) { $this->validate($this->request, Comment::COMMENT_RULES); @@ -45,16 +84,24 @@ public function storeWikiComment(Team $team, Space $space, Wiki $wiki) ]); } + /** + * Notify all users that are mentioned in comment. + * + * @param $mentions + * @param $wiki + * @param null $page + * @return bool + */ public function notifyMentionedUsers($mentions, $wiki, $page = null) { foreach ($mentions as $mention) { $mention = str_replace('@', '', $mention); - $user = \App\Models\User::where('slug', $mention)->first(); + $user = $this->user->getUser($mention);; if(is_null($page)) { $url = route('wikis.show', [Auth::user()->getTeam()->slug, $wiki->space->slug, $wiki->slug]); - \Notifynder::category('wiki.user.mentioned') + Notifynder::category('wiki.user.mentioned') ->from(Auth::user()->id) ->to($user->id) ->url($url) @@ -62,7 +109,7 @@ public function notifyMentionedUsers($mentions, $wiki, $page = null) ->send(); } else { $url = route('pages.show', [Auth::user()->getTeam()->slug, $wiki->space->slug, $wiki->slug, $page->slug]); - \Notifynder::category('page.user.mentioned') + Notifynder::category('page.user.mentioned') ->from(Auth::user()->id) ->to($user->id) ->url($url) @@ -75,6 +122,15 @@ public function notifyMentionedUsers($mentions, $wiki, $page = null) return true; } + /** + * Create a new page comment. + * + * @param \App\Models\Team $team + * @param \App\Models\Space $space + * @param \App\Models\Wiki $wiki + * @param \App\Models\Page $page + * @return \Illuminate\Http\RedirectResponse + */ public function storePageComment(Team $team, Space $space, Wiki $wiki, Page $page) { @@ -95,15 +151,25 @@ public function storePageComment(Team $team, Space $space, Wiki $wiki, Page $pag ]); } + /** + * Delete comment. + * + * @return \Illuminate\Http\JsonResponse + */ public function destroy() { - $this->comment->where('id', $this->request->get('commentId'))->where('user_id', Auth::user()->id)->delete(); + $this->comment->deleteComment($this->request->get('commentId')); return response()->json([ 'deleted' => true, ], 200); } + /** + * Update comment. + * + * @return \Illuminate\Http\JsonResponse + */ public function update() { $this->validate($this->request, Comment::COMMENT_RULES); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2e61854b..bf15c5df 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -10,6 +10,11 @@ */ class HomeController extends Controller { + /** + * Show home view to guest. + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function home() { return view('home'); diff --git a/app/Http/Controllers/IntegrationController.php b/app/Http/Controllers/IntegrationController.php index 963083cf..12757eb3 100644 --- a/app/Http/Controllers/IntegrationController.php +++ b/app/Http/Controllers/IntegrationController.php @@ -4,29 +4,54 @@ use DB; use Carbon\Carbon; +use App\Models\Team; +use App\Models\Integration; use Illuminate\Http\Request; -use App\Models\{ - Team, Integration -}; +/** + * Class IntegrationController + * + * @package App\Http\Controllers + * @author Zeeshan Ahmed + */ class IntegrationController extends Controller { + /** + * @var \Illuminate\Http\Request + */ protected $request; + /** + * @var \App\Models\Integration + */ protected $integration; + /** + * IntegrationController constructor. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Integration $integration + */ public function __construct(Request $request, Integration $integration) { $this->request = $request; $this->integration = $integration; } + /** + * Store a new slack integration. + * + * @param \App\Models\Team $team + * @return \Illuminate\Http\RedirectResponse + * + */ public function storeSlackIntegration(Team $team) { $this->validate($this->request, Integration::INTEGRATION_RULES); $teamIntegration = $this->integration->storeSlackIntegration($this->request->all(), $team->id); + // Update all the integration actions on which user want to be notified on slack. foreach ($this->request->integrations as $integration) { DB::table('team_integration_actions')->insert([ 'integration_id' => $teamIntegration->id, diff --git a/app/Http/Controllers/InviteController.php b/app/Http/Controllers/InviteController.php index 3bf15b3f..963464ab 100644 --- a/app/Http/Controllers/InviteController.php +++ b/app/Http/Controllers/InviteController.php @@ -3,22 +3,46 @@ namespace App\Http\Controllers; use Mail; -use Illuminate\Http\Request; use App\Models\Team; use App\Models\Invite; +use Illuminate\Http\Request; +/** + * Class InviteController + * + * @package App\Http\Controllers + * @author Zeeshan Ahmed + */ class InviteController extends Controller { + /** + * @var \Illuminate\Http\Request + */ protected $request; + /** + * @var \App\Models\Invite + */ protected $invite; + /** + * InviteController constructor. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Invite $invite + */ public function __construct(Request $request, Invite $invite) { $this->request = $request; $this->invite = $invite; } + /** + * Invite user to team. + * + * @param \App\Models\Team $team + * @return \Illuminate\Http\RedirectResponse + */ public function store(Team $team) { $this->validate($this->request, Invite::INVITE_RULES, [ @@ -36,6 +60,13 @@ public function store(Team $team) ]); } + /** + * Send invitation mail to the invited user. + * + * @param $invitation + * @param $team + * @return bool + */ public function sendInvitationEmail($invitation, $team) { Mail::send('mails.invitation', ['invitation' => $invitation, 'team' => $team], function ($message) use ($invitation, $team) { @@ -47,9 +78,16 @@ public function sendInvitationEmail($invitation, $team) return true; } + /** + * Delete pending invitation. + * + * @param \App\Models\Team $team + * @param $invitationCode + * @return \Illuminate\Http\RedirectResponse + */ public function destroy(Team $team, $invitationCode) { - $this->invite->where('code', $invitationCode)->where('team_id', $team->id)->delete(); + $this->invite->deleteInvitation($invitationCode, $team->id); return redirect()->back()->with([ 'alert' => 'Invitation successfully removed.', diff --git a/app/Http/Controllers/LikeController.php b/app/Http/Controllers/LikeController.php index 3f13af8f..4e8c8f4c 100644 --- a/app/Http/Controllers/LikeController.php +++ b/app/Http/Controllers/LikeController.php @@ -9,18 +9,48 @@ use App\Models\Comment; use Illuminate\Http\Request; +/** + * Class LikeController + * + * @package App\Http\Controllers + * @author Zeeshan Ahmed + */ class LikeController extends Controller { + /** + * @var \App\Models\Like + */ protected $like; + /** + * @var \App\Models\Wiki + */ protected $wiki; + /** + * @var \Illuminate\Http\Request + */ protected $request; + /** + * @var \App\Models\Page + */ protected $page; + /** + * @var \App\Models\Comment + */ protected $comment; + /** + * LikeController constructor. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Like $like + * @param \App\Models\Wiki $wiki + * @param \App\Models\Page $page + * @param \App\Models\Comment $comment + */ public function __construct(Request $request, Like $like, Wiki $wiki, Page $page, Comment $comment) { $this->request = $request; @@ -30,12 +60,18 @@ public function __construct(Request $request, Like $like, Wiki $wiki, Page $page $this->comment = $comment; } + /** + * Check type of subject(Comment, Wiki, Page) that is liked and then store the like if the subject + * is un-liked then remove the like. + * + * @return \Illuminate\Http\JsonResponse + */ public function storeLike() { if($this->request->get('subjectType') === 'wiki') { - $wiki = $this->wiki->where('slug', $this->request->get('subject'))->first(); + $wiki = $this->wiki->getWiki($this->request->get('subject')); - $like = $this->handleLike('App\Models\Wiki', $wiki->id); + $like = $this->handleLike(Wiki::class, $wiki->id); if($like) { return response()->json([ @@ -49,9 +85,9 @@ public function storeLike() } if($this->request->get('subjectType') === 'page') { - $page = $this->page->where('slug', $this->request->get('subject'))->first(); + $page = $this->page->getPage($this->request->get('subject')); - $like = $this->handleLike('App\Models\Page', $page->id); + $like = $this->handleLike(Page::class, $page->id); if($like) { return response()->json([ @@ -67,7 +103,7 @@ public function storeLike() if($this->request->get('subjectType') === 'comment') { $comment = $this->comment->find($this->request->get('subject')); - $like = $this->handleLike('App\Models\Comment', $comment->id); + $like = $this->handleLike(Comment::class, $comment->id); if($like) { return response()->json([ @@ -79,8 +115,17 @@ public function storeLike() 'like' => false, ], 200); } + + abort(404); } + /** + * Create new like or if like already exists then restore it. + * + * @param $subject + * @param $subjectId + * @return bool + */ public function handleLike($subject, $subjectId) { $existing_like = $this diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php index f41007a5..3d07db64 100644 --- a/app/Http/Controllers/NotificationController.php +++ b/app/Http/Controllers/NotificationController.php @@ -6,8 +6,21 @@ use App\Models\Team; use App\Models\User; +/** + * Class NotificationController + * + * @package App\Http\Controllers + * @author Zeeshan Ahmed + */ class NotificationController extends Controller { + /** + * Mark all notifications as read. + * + * @param \App\Models\Team $team + * @param \App\Models\User $user + * @return \Illuminate\Http\RedirectResponse + */ public function readAll(Team $team, User $user) { Auth::user()->readAllNotifications(); @@ -15,6 +28,11 @@ public function readAll(Team $team, User $user) return redirect()->back(); } + /** + * Get all notifications that are not read by user. + * + * @return mixed + */ public function getNotificationsNotRead() { $query = Auth::user()->getNotificationRelation()->byRead(0)->orderBy('created_at', 'desc'); diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php index 65cd0a5e..78bf6fdc 100644 --- a/app/Http/Controllers/RoleController.php +++ b/app/Http/Controllers/RoleController.php @@ -2,40 +2,76 @@ namespace App\Http\Controllers; +use DB; use Carbon\Carbon; use App\Models\Team; use App\Models\Role; use App\Models\Space; use Illuminate\Http\Request; -use Illuminate\Support\Facades\DB; +/** + * Class RoleController + * + * @package App\Http\Controllers + */ class RoleController extends Controller { + /** + * @var \Illuminate\Http\Request + */ protected $request; + /** + * @var \App\Models\Role + */ protected $role; - public function __construct(Request $request, Role $role) + /** + * RoleController constructor. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Role $role + * @param \App\Models\Space $space + */ + public function __construct(Request $request, Role $role, Space $space) { - $this->request = $request; + $this->space = $space; $this->role = $role; + $this->request = $request; } + /** + * Get all roles of team. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function index(Team $team) { - $spaces = (new Space)->getTeamSpaces($team->id); + $spaces = $this->space->getTeamSpaces($team->id); - $roles = $this->role->where('team_id', $team->id)->latest()->with(['members', 'permissions'])->get(); + $roles = $this->role->getTeamRoles($team->id); return view('role.index', compact('team', 'roles', 'spaces')); } + /** + * Show a view to create new role. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function create(Team $team) { return view('role.create', compact('team')); } - + /** + * Create a new team role. + * + * @param \App\Models\Team $team + * @return \Illuminate\Http\RedirectResponse + */ public function store(Team $team) { $this->validate($this->request, Role::ROLE_RULES); @@ -71,11 +107,25 @@ public function store(Team $team) ]); } + /** + * Show a view to update an existing role. + * + * @param \App\Models\Team $team + * @param \App\Models\Role $role + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function edit(Team $team, Role $role) { return view('role.edit', compact('team', 'role')); } + /** + * Update an existing role. + * + * @param \App\Models\Team $team + * @param \App\Models\Role $role + * @return \Illuminate\Http\RedirectResponse + */ public function update(Team $team, Role $role) { $this->validate($this->request, Role::ROLE_RULES); @@ -114,6 +164,13 @@ public function update(Team $team, Role $role) ]); } + /** + * Delete an existing role. + * + * @param \App\Models\Team $team + * @param \App\Models\Role $role + * @return \Illuminate\Http\RedirectResponse + */ public function destroy(Team $team, Role $role) { $this->role->find($role->id)->delete(); diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index c8bb32d7..b0cd5d78 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -5,91 +5,43 @@ use App\Models\Tag; use Illuminate\Http\Request; +/** + * Class TagController + * + * @package App\Http\Controllers + * @author Zeeshan Ahmed + */ class TagController extends Controller { - protected $request; - - protected $tag; - - public function __construct(Request $request, Tag $tag) - { - $this->request = $request; - $this->tag = $tag; - } - /** - * Display a listing of the resource. - * - * @return \Illuminate\Http\Response + * @var \Illuminate\Http\Request */ - public function index() - { - return $this->tag->where('name', 'like', '%' . $this->request->get('q') . '%')->get(); - } - - /** - * Show the form for creating a new resource. - * - * @return \Illuminate\Http\Response - */ - public function create() - { - // - } - - /** - * Store a newly created resource in storage. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function store(Request $request) - { - // - } - - /** - * Display the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response - */ - public function show($id) - { - // - } + protected $request; /** - * Show the form for editing the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response + * @var \App\Models\Tag */ - public function edit($id) - { - // - } + protected $tag; /** - * Update the specified resource in storage. + * TagController constructor. * - * @param \Illuminate\Http\Request $request - * @param int $id - * @return \Illuminate\Http\Response + * @param \Illuminate\Http\Request $request + * @param \App\Models\Tag $tag */ - public function update(Request $request, $id) + public function __construct(Request $request, Tag $tag) { - // + $this->tag = $tag; + $this->request = $request; } /** - * Remove the specified resource from storage. + * Display a listing of the resource. * - * @param int $id * @return \Illuminate\Http\Response */ - public function destroy($id) + public function index() { - // + return $this->tag->filterTags($this->request->get('q')); } } diff --git a/app/Http/Controllers/TeamController.php b/app/Http/Controllers/TeamController.php index 04b0762c..e041f568 100644 --- a/app/Http/Controllers/TeamController.php +++ b/app/Http/Controllers/TeamController.php @@ -14,18 +14,48 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +/** + * Class TeamController + * + * @package App\Http\Controllers + * @author Zeeshan Ahmed + */ class TeamController extends Controller { + /** + * @var \Illuminate\Http\Request + */ private $request; + /** + * @var \App\Models\Team + */ private $team; + /** + * @var \App\Models\User + */ private $user; + /** + * @var \App\Models\Role + */ private $role; + /** + * @var + */ private $space; + /** + * TeamController constructor. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Team $team + * @param \App\Models\Role $role + * @param \App\Models\User $user + * @param \App\Models\Space $space + */ public function __construct(Request $request, Team $team, Role $role, User $user, Space $space) { $this->user = $user; @@ -34,6 +64,12 @@ public function __construct(Request $request, Team $team, Role $role, User $user $this->role = $role; } + /** + * Get all the members of a team in a view. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function getMembers(Team $team) { $teamMembers = $this->team->getMembers($team); @@ -41,6 +77,13 @@ public function getMembers(Team $team) return view('team.members', compact('team', 'teamMembers')); } + /** + * Show a join team view to invited user. + * + * @param \App\Models\Team $team + * @param $hash + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function join(Team $team, $hash) { Auth::logout(); @@ -50,11 +93,12 @@ public function join(Team $team, $hash) return view('team.join', compact('team', 'hash', 'invitation')); } - public function isContentTypeJson() - { - return $this->request->header('content-type') == 'application/json'; - } - + /** + * Update team. + * + * @param \App\Models\Team $team + * @return \Illuminate\Http\RedirectResponse + */ public function update(Team $team) { if($team->name === $this->request->get('team_name')) { @@ -76,6 +120,12 @@ public function update(Team $team) ]); } + /** + * Delete a team. + * + * @param \App\Models\Team $team + * @return \Illuminate\Http\RedirectResponse + */ public function destroy(Team $team) { $this->team->deleteTeam($team->id); @@ -88,11 +138,18 @@ public function destroy(Team $team) ]); } + /** + * Make invited user member of a team. + * + * @param \App\Models\Team $team + * @param $hash + * @return \Illuminate\Http\RedirectResponse + */ public function postJoin(Team $team, $hash) { $this->validate($this->request, Team::JOIN_TEAM_RULES, [ 'exists' => 'Specified team does\'t exists.', - 'team_has_email' => 'This team has alredy a user with this email address.', + 'team_has_email' => 'This team has already a user with this email address.', ]); $user = $this->user->createUser($this->request->all()); @@ -122,16 +179,32 @@ public function postJoin(Team $team, $hash) ]); } + /** + * Show a view to invite user to a team. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function inviteUsers(Team $team) { return view('team.users.invite', compact('team')); } + /** + * Show login view to guest. + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function login() { return view('team.login'); } + /** + * Login user to team. + * + * @return \Illuminate\Http\RedirectResponse + */ public function postLogin() { $this->validate($this->request, User::LOGIN_RULES, [ @@ -147,15 +220,25 @@ public function postLogin() } return redirect()->back()->withErrors([ - 'wrong_credential' => 'Email or password is not valid.' + 'wrong_credential' => 'Email or password is not valid.', ]); } + /** + * Show create team view. + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function create() { return view('team.create'); } + /** + * Create a new team. + * + * @return \Illuminate\Http\RedirectResponse + */ public function store() { $this->validate($this->request, Team::CREATE_TEAM_RULES); @@ -173,6 +256,12 @@ public function store() ]); } + /** + * Create admin role when a user create a team. + * + * @param $team + * @return bool + */ public function createAdminsRole($team) { // Create role @@ -208,11 +297,23 @@ public function createAdminsRole($team) return true; } + /** + * Show general setting view. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function generalSettings(Team $team) { return view('team.setting.general', compact('team')); } + /** + * Get all the members of a team. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function membersSettings(Team $team) { $members = $this->team->getMembers($team); @@ -224,6 +325,12 @@ public function membersSettings(Team $team) return view('team.setting.members', compact('team', 'members', 'roles', 'invitations')); } + /** + * Upload team logo. + * + * @param \App\Models\Team $team + * @return \Illuminate\Http\RedirectResponse + */ public function uploadLogo(Team $team) { $image = $this->request->file('team_logo'); @@ -242,6 +349,11 @@ public function uploadLogo(Team $team) ]); } + /** + * Filter members of a team. + * + * @return mixed + */ public function filterMembers() { $members = $this->team->find(Auth::user()->getTeam()->id)->with(['members' => function ($query) { @@ -251,6 +363,12 @@ public function filterMembers() return $members; } + /** + * Get all the integrations of a team. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function integration(Team $team) { $integrations = (new Integration)->getTeamIntegration($team->id); @@ -258,11 +376,22 @@ public function integration(Team $team) return view('team.setting.integration', compact('team', 'integrations')); } + /** + * Create a new slack integration view. + * + * @param \App\Models\Team $team + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function slackIntegration(Team $team) { return view('team.setting.slack', compact('team')); } + /** + * Team search functionality + * + * @return \Illuminate\Http\JsonResponse + */ public function search() { $data = []; @@ -282,6 +411,13 @@ public function search() return response()->json($data, 200); } + /** + * Format search result. + * + * @param $members + * @param $team + * @return array + */ public function formatMembers($members, $team) { $data = []; @@ -296,6 +432,13 @@ public function formatMembers($members, $team) return $data; } + /** + * Format search result. + * + * @param $pages + * @param $team + * @return array + */ public function formatPages($pages, $team) { $data = []; @@ -310,6 +453,13 @@ public function formatPages($pages, $team) return $data; } + /** + * Format search result. + * + * @param $wikis + * @param $team + * @return array + */ public function formatWikis($wikis, $team) { $data = []; @@ -324,6 +474,13 @@ public function formatWikis($wikis, $team) return $data; } + /** + * Format search result. + * + * @param $spaces + * @param $team + * @return array + */ public function formatSpaces($spaces, $team) { $data = []; diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 0acc0ae5..c19bf0db 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -293,11 +293,21 @@ public function getTeamMembers() return $this->team->where('id', Auth::user()->getTeam()->id)->with(['members'])->first()->members; } + /** + * Show password reset form. + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function showLinkRequestForm() { return view('user.passwords.email'); } + /** + * Send password reset email to user. + * + * @return \Illuminate\Http\RedirectResponse + */ public function sendResetLinkEmail() { $this->validate($this->request, [ @@ -324,6 +334,13 @@ public function sendResetLinkEmail() ]); } + /** + * Send password reset email. + * + * @param $email + * @param $token + * @return bool + */ public function sendResetPasswordEmail($email, $token) { Mail::send('mails.reset-password', ['email' => $email, 'token' => $token], function ($message) use ($email) { @@ -335,6 +352,12 @@ public function sendResetPasswordEmail($email, $token) return true; } + /** + * Show change password form. + * + * @param $token + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ public function showResetForm($token) { $passwordReset = DB::table('password_resets')->where('token', $token)->get(); @@ -346,6 +369,12 @@ public function showResetForm($token) return view('user.passwords.reset', compact('token')); } + /** + * Update user account password. + * + * @param $token + * @return \Illuminate\Http\RedirectResponse + */ public function reset($token) { $this->validate($this->request, [ @@ -368,6 +397,12 @@ public function reset($token) ]); } + /** + * Get the user. + * + * @param $passwordReset + * @return array|null|\stdClass + */ public function findUser($passwordReset) { return $this->team->getUser($passwordReset); diff --git a/app/Models/Comment.php b/app/Models/Comment.php index eab61ce9..db4ef8e3 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -110,7 +110,7 @@ public function storeComment($subjectId, $subjectType, $data) */ public function deleteComment($id) { - return $this->find($id)->delete(); + return $this->find($id)->where('user_id', Auth::user()->id)->delete(); } /** diff --git a/app/Models/Invite.php b/app/Models/Invite.php index d77dfdec..858cf5dc 100644 --- a/app/Models/Invite.php +++ b/app/Models/Invite.php @@ -100,4 +100,16 @@ public function claimAccount($teamId, $hash) 'claimed_at' => Carbon::now(), ]); } + + /** + * Delete pending invitation. + * + * @param $invitationCode + * @param $teamId + * @return mixed + */ + public function deleteInvitation($invitationCode, $teamId) + { + return $this->where('code', $invitationCode)->where('team_id', $teamId)->delete(); + } } diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 3900f15a..9cd8e60e 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -153,4 +153,15 @@ public function updateTags($tags, $subjectType, $subjectId) return true; } + + /** + * Filter Tags. + * + * @param $query + * @return mixed + */ + public function filterTags($query) + { + return $this->where('name', 'like', '%' . $query . '%')->get(); + } } diff --git a/app/Models/Team.php b/app/Models/Team.php index ecc144e6..ffc472bd 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -191,7 +191,7 @@ public function getTeam($teamSlug) /** * Create a new team. * - * @param $team array + * @param $team * @return \App\Models\Team */ public function postTeam($team) diff --git a/app/Models/User.php b/app/Models/User.php index 7b75ba18..c7574158 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -180,7 +180,7 @@ public function pages() */ public function getUser($userSlug) { - $user = $this->where('slug', '=', $userSlug)->first(); + $user = $this->where('slug', $userSlug)->first(); if($user) { return $user;