Appeal Process upgrade

Changed the appeal process so that each request is tracked in the
database to make reviewing and time limits easier to manage.

An email is still sent but it's just a notifcation to let the admin know
an appeal has been filed.
This commit is contained in:
ro 2024-02-08 14:37:34 -06:00
parent 9be54fa13c
commit bce9a430aa
7 changed files with 96 additions and 37 deletions

View file

@ -0,0 +1,49 @@
<?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 {
$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");
};
}
}

View file

@ -1,30 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Mail\LocationAppeal;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class AppealMailController 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 {
Mail::to(env('TBS_ADMIN_EMAIL'))->send(new LocationAppeal($request->location, $request->sponsor));
//return redirect('/appeals');
return back()->with('message', "Appeal Filed");
};
}
}

34
app/Models/Appeal.php Normal file
View file

@ -0,0 +1,34 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Appeal extends Model
{
use HasFactory;
use SoftDeletes;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = "appeal";
protected $primaryKey = 'id';
public $incrementing = true;
protected $fillable = [
"uuid",
"location",
"location_admin",
"sponsor",
"description",
"approved",
"reviewed",
"created_at",
"updated_at"
];
}

View file

@ -97,6 +97,11 @@ main > section > article {
min-height: 400px;
}
textarea[name="appeal_description"] {
width: 300px;
height: 200px;
}
/* NAV */
#main-nav {

View file

@ -1,5 +1,3 @@
<div>
A quick test to see if it works.<br />
Appeal for: {{$location}}<br />
Appeal Sponsor: {{$sponsor}}<br />
Appeal filed for: {{$location}}<br />
</div>

View file

@ -45,12 +45,15 @@
<form action="/appeal" method="post" enctype="multipart/form-data">
@csrf
<label>Appeal Location</label><br />
<input type="text" name="location" value="" />
<br />
<input type="text" name="location" value="" /><br />
<label>Appeal Location Admin</label><br />
<input type="text" name="location_admin" value="" /><br />
<label>Appeal Sponsor</label><br />
<input type="text" name="sponsor" value="" /><br />
<label>What is 1+1?</label><br />
<input type="text" name="question" value="" /><br />
<label>Appeal Summary</label><br />
<textarea name="appeal_description">Appeal Summary</textarea>
<input type="hidden" name="h1" value="" /><br />
<input type="submit" value="File Appeal" name="submit_button">
</form>

View file

@ -6,7 +6,7 @@ use App\Http\Controllers\AuthController;
use App\Http\Controllers\DenController;
use App\Http\Controllers\LocationController;
use App\Http\Controllers\ExportController;
use App\Http\Controllers\AppealMailController;
use App\Http\Controllers\AppealController;
/*
|--------------------------------------------------------------------------
@ -26,7 +26,7 @@ Route::get("/about", [FrontIndexController::class, 'about']);
Route::get("/location/{uuid}", [FrontIndexController::class, 'location']);
Route::get("/appeals", [FrontIndexController::class, 'appeals']);
Route::post("/search", [FrontIndexController::class, 'indexSearch']);
Route::post("/appeal", [AppealMailController::class, 'sendAppeal']);
Route::post("/appeal", [AppealController::class, 'sendAppeal']);
//exports
Route::get("/exports", [ExportController::class, 'exportIndex']);