Skip to content

Commit

Permalink
Add validation of name and email
Browse files Browse the repository at this point in the history
These changes were provided by @Jeroen-G in #89
  • Loading branch information
okaufmann committed May 30, 2020
1 parent 59a407b commit fee391a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions stubs/controllers/TeamController.stub
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class TeamController extends Controller
*/
public function store(Request $request)
{
$request->validate([
'name' => 'required|string',
]);

$teamModel = config('teamwork.team_model');

$team = $teamModel::create([
Expand Down Expand Up @@ -99,6 +103,10 @@ class TeamController extends Controller
*/
public function update(Request $request, $id)
{
$request->validate([
'name' => 'required|string',
]);

$teamModel = config('teamwork.team_model');

$team = $teamModel::findOrFail($id);
Expand Down
8 changes: 6 additions & 2 deletions stubs/controllers/TeamMemberController.stub
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class TeamMemberController extends Controller
*/
public function invite(Request $request, $team_id)
{
$request->validate([
'email' => 'required|email',
]);

$teamModel = config('teamwork.team_model');
$team = $teamModel::findOrFail($team_id);

Expand All @@ -80,13 +84,13 @@ class TeamMemberController extends Controller
'email' => 'The email address is already invited to the team.'
]);
}

return redirect(route('teams.members.show', $team->id));
}

/**
* Resend an invitation mail.
*
*
* @param $invite_id
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
Expand Down

0 comments on commit fee391a

Please sign in to comment.