-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 624-recent-updates-feed-on-main-page
- Loading branch information
Showing
82 changed files
with
123,878 additions
and
1,017 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/Http/Controllers/Admin/DeleteAccountRequestController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\DeleteAccountRequest; | ||
use App\Http\Controllers\Controller; | ||
use App\Http\Controllers\Traits\Responds; | ||
use App\Jobs\SendAccountRequestDeletionNotification; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
|
||
class DeleteAccountRequestController extends Controller | ||
{ | ||
use Responds; | ||
|
||
/** | ||
* @return \Illuminate\Http\JsonResponse | ||
* @throws \Illuminate\Auth\Access\AuthorizationException | ||
*/ | ||
public function index(): JsonResponse | ||
{ | ||
$this->authorize('viewAny', DeleteAccountRequest::class); | ||
|
||
return $this->success(DeleteAccountRequest::orderByDesc('id')->paginate(20)); | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Http\JsonResponse | ||
*/ | ||
public function myIndex(): JsonResponse | ||
{ | ||
return $this->success(DeleteAccountRequest::where('user_id', auth()->id()) | ||
->orderByDesc('id') | ||
->paginate(20)); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\JsonResponse | ||
* @throws \Illuminate\Auth\Access\AuthorizationException | ||
*/ | ||
public function create(Request $request): JsonResponse | ||
{ | ||
$this->authorize('create', DeleteAccountRequest::class); | ||
|
||
$deleteAccountRequest = DeleteAccountRequest::create($request->only([ | ||
'reason', | ||
]) + [ | ||
'user_id' => $request->user()->id, | ||
]); | ||
|
||
dispatch(new SendAccountRequestDeletionNotification($deleteAccountRequest)); | ||
|
||
return $this->success($deleteAccountRequest); | ||
} | ||
|
||
/** | ||
* @param \App\DeleteAccountRequest $deleteRequest | ||
* @return \Illuminate\Http\JsonResponse | ||
* @throws \Illuminate\Auth\Access\AuthorizationException | ||
*/ | ||
public function delete(DeleteAccountRequest $deleteRequest): JsonResponse | ||
{ | ||
$this->authorize('delete', $deleteRequest); | ||
|
||
$deleteRequest->delete(); | ||
|
||
return $this->created(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api\v1; | ||
|
||
use App\Contact; | ||
use App\Http\Controllers\Controller; | ||
use App\Http\Controllers\Traits\Responds; | ||
use App\Mail\ContactRequest; | ||
use App\Mail\ContactUser; | ||
use App\User; | ||
use Illuminate\Http\Request; | ||
use ReCaptcha\ReCaptcha; | ||
use Illuminate\Support\Facades\Mail; | ||
|
||
class ContactController extends Controller | ||
{ | ||
use Responds; | ||
|
||
/** | ||
* Contact administrators. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\JsonResponse | ||
*/ | ||
public function send(Request $request) | ||
{ | ||
$this->validate($request, [ | ||
'name' => 'required|min:3', | ||
'email' => 'required|email', | ||
'subject' => 'required', | ||
'message' => 'required', | ||
'recaptcha' => 'required', | ||
]); | ||
|
||
$recaptcha = new ReCaptcha(config('services.google.recaptcha')); | ||
$verify = $recaptcha->verify($request->recaptcha, $request->ip()); | ||
|
||
if (!$verify->isSuccess()) { | ||
return $this->validationError([ | ||
'recaptcha' => ['Please verify you are not a robot.'], | ||
]); | ||
} | ||
|
||
Mail::to($this->getSubscribedAdmins())->queue(new ContactRequest((object)$request->all())); | ||
|
||
return $this->success('Message Sent'); | ||
} | ||
|
||
/** | ||
* Get all Staton Lab admins who subscribed to contact requests. | ||
*/ | ||
protected function getSubscribedAdmins() | ||
{ | ||
// return User::with('role')->whereHas('subscriptionTopics', function ($query) { | ||
// $query->where('key', 'contact'); | ||
// })->get()->reject(function ($user) { | ||
// return $user->role->name !== 'Admin'; | ||
// })->map(function ($user) { | ||
// return $user->email; | ||
// }); | ||
return collect([ | ||
// "[email protected]", | ||
"[email protected]", | ||
// "[email protected]" | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ trait Observes | |
'Pinyon Pine', | ||
'Sassafras', | ||
'Ozark Chinquapin', | ||
'Alaskan Willow', | ||
'Other', | ||
]; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.