Skip to content

Commit

Permalink
fix validation database connection
Browse files Browse the repository at this point in the history
  • Loading branch information
adereksisusanto committed Apr 23, 2024
1 parent a77ae76 commit 42ba4b3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/Http/Controllers/Auth/PasswordResetLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ public function create(): Response

public function store(Request $request): RedirectResponse
{
$connection = config('translations.database_connection');
$request->validate([
'email' => 'required|email|exists:ltu_contributors,email',
'email' => 'required|email|exists:'.($connection ? $connection.'.' : '').'ltu_contributors,email',
]);

$token = Str::random();

$user = Contributor::firstWhere('email', $request->email);

if ($user) {
cache(["password.reset.$user->id" => $token],
cache(
["password.reset.$user->id" => $token],
now()->addMinutes(60)
);

Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/ContributorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ public function create(): Modal

public function store(Request $request): RedirectResponse
{
$connection = config('translations.database_connection');
$request->validate([
'role' => 'required|integer',
'email' => 'required|email|unique:ltu_contributors,email',
'email' => 'required|email|unique:'.($connection ? $connection.'.' : '').'ltu_contributors,email',
]);

do {
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public function edit(Request $request): Response

public function update(Request $request): RedirectResponse
{
$connection = config('translations.database_connection');
$request->validate([
'name' => ['required', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:ltu_contributors,email,'.$request->user()->id],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.($connection ? $connection.'.' : '').'ltu_contributors,email,'.$request->user()->id],
]);

$request->user()->update($request->only('name', 'email'));
Expand Down
6 changes: 4 additions & 2 deletions src/Http/Controllers/SourcePhraseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ public function create(): Modal

public function store(Request $request): RedirectResponse
{
$connection = config('translations.database_connection');
$request->validate([
'key' => ['required', 'regex:/^[\w. ]+$/u'],
'file' => ['required', 'integer', 'exists:ltu_translation_files,id'],
'file' => ['required', 'integer', 'exists:'.($connection ? $connection.'.' : '').'ltu_translation_files,id'],
'content' => ['required', 'string'],
]);

Expand Down Expand Up @@ -111,10 +112,11 @@ public function edit(Phrase $phrase): Response|RedirectResponse

public function update(Phrase $phrase, Request $request): RedirectResponse
{
$connection = config('translations.database_connection');
$request->validate([
'note' => 'nullable|string',
'phrase' => 'required|string',
'file' => 'required|integer|exists:ltu_translation_files,id',
'file' => 'required|integer|exists:'.($connection ? $connection.'.' : '').'ltu_translation_files,id',
]);

$phrase->update([
Expand Down

0 comments on commit 42ba4b3

Please sign in to comment.