added support for inviting list collaborators
This commit is contained in:
parent
cd2c8adaa8
commit
0787b75780
21 changed files with 393 additions and 34 deletions
55
app/Http/Requests/CreateInvitationRequest.php
Normal file
55
app/Http/Requests/CreateInvitationRequest.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CreateInvitationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'emails' => 'required|array',
|
||||
'emails.*' => [
|
||||
'required',
|
||||
'email',
|
||||
// They haven't been invited to the movie list
|
||||
Rule::unique('invitations', 'email')
|
||||
->where('movie_list_id', $this->input('movie_list_id')),
|
||||
// The user isn't already a collaborator
|
||||
Rule::notIn(
|
||||
DB::table('movie_list_user')
|
||||
->join('users', 'users.id', '=', 'movie_list_user.user_id')
|
||||
->where('movie_list_id', $this->input('movie_list_id'))
|
||||
->pluck('users.email')
|
||||
->push($this->user()->email)
|
||||
->toArray()
|
||||
),
|
||||
],
|
||||
'movie_list_id' => 'required|exists:movie_lists,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'emails.*.unique' => 'The email address is already invited to this movie list.',
|
||||
'emails.*.not_in' => ':input is already a collaborator.',
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/PasswordResetRequest.php
Normal file
31
app/Http/Requests/PasswordResetRequest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PasswordResetRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'password_confirmation' => 'string',
|
||||
'token' => 'required|string',
|
||||
'email' => 'required|email|exists:users,email',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,6 @@ class RegisterRequest extends FormRequest
|
|||
return [
|
||||
'username' => 'required|string|max:255|unique:users',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue