thebadspace/app/Http/Controllers/AppealController.php
ro da0ddb3ef0 Plugged in repository class for location data
Seperated data logic for locations and put it into its own repository
class for better organization and readability of controller classes.

Data methods are still simple so no need for an interface class just
yet, but will probably implement at a later date
2024-02-09 14:53:08 -06:00

51 lines
1.6 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Mail\LocationAppeal;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Ramsey\Uuid\Uuid;
use App\Models\Appeal;
class AppealController extends Controller
{
/**
* Send appeal request
*/
public function sendAppeal(Request $request)
{
//$order = Order::findOrFail($request->order_id);
$token = csrf_token();
if ($request->h1 != '' || $request->question != 2) {
return back()->withErrors([
'error' => 'Invalid Request',
]);
} else {
$check = Appeal::where("location", $request->location)->first();
if ($check) {
return back()->withErrors([
'error' => 'Appeal already in process for Location',
]);
} else {
//TODO: Add empty string filtering and check if location exists in DB
$new = Appeal::create([
'uuid' => Uuid::uuid4(),
'location' => $request->location,
'location_admin' => $request->location_admin,
'sponsor' => $request->sponsor,
'description' => $request->appeal_description,
'approved' => false,
'reviewed' => false,
]);
Mail::to(env('TBS_ADMIN_EMAIL'))->send(new LocationAppeal($request->location, $request->sponsor));
}
//return redirect('/appeals');
return back()->with('message', "Appeal Filed");
};
}
}