-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,295 additions
and
218 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
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,74 @@ | ||
<?php | ||
namespace App\Http\Controllers\Appeal; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Mail\AppealApproved; | ||
use App\Models\Appeal\Appeal; | ||
use App\Models\SaBan; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Mail; | ||
|
||
class AppealController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$appeals = Appeal::all(); | ||
return view('appeals.create', compact('appeals')); | ||
} | ||
|
||
public function create() | ||
{ | ||
return view('appeals.create'); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
$validated = $request->validate([ | ||
'ban_type' => 'required|string', | ||
'steamid' => 'required_if:ban_type,Steam ID|nullable|string', | ||
'ip' => 'required_if:ban_type,IP|nullable|ip', | ||
'name' => 'required|string', | ||
'reason' => 'required|string', | ||
'email' => 'required|email', | ||
]); | ||
if(SaBan::where('player_steamid', $validated['steamid']) | ||
->where('status', 'ACTIVE') | ||
->exists()) { | ||
$data = $request->only(['ban_type', 'steamid', 'ip', 'name', 'reason', 'email']); | ||
$data['status'] = 'PENDING'; | ||
// Save the appeal | ||
Appeal::create($data); | ||
|
||
return redirect()->route('appeals.create')->with('success', 'Appeal submitted successfully.'); | ||
} | ||
else { | ||
return redirect()->route('appeals.create')->with('error', 'No active bans exists for this Steam ID or IP'); | ||
} | ||
} | ||
|
||
public function list() | ||
{ | ||
$appeals = Appeal::orderBy('created_at', 'desc')->get(); | ||
return view('appeals.list', compact('appeals')); | ||
} | ||
|
||
public function view($id) | ||
{ | ||
$appeal = Appeal::findOrFail($id); | ||
return view('appeals.show', compact('appeal')); | ||
} | ||
|
||
public function updateStatus(Request $request, $id) | ||
{ | ||
$request->validate([ | ||
'status' => 'required|in:APPROVED,REJECTED', | ||
]); | ||
|
||
$appeal = Appeal::findOrFail($id); | ||
$appeal->status = $request->input('status'); | ||
$appeal->save(); | ||
Mail::to($appeal->email)->send(new AppealApproved($appeal)); | ||
|
||
return redirect()->route('appeals.list', $appeal->id)->with('success', 'Appeal status updated successfully.'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Report; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Report\Report; | ||
use App\Models\SaServer; | ||
use Illuminate\Http\Request; | ||
|
||
class ReportController extends Controller | ||
{ | ||
public function create() | ||
{ | ||
$servers = SaServer::all(); | ||
return view('reports.create', compact('servers')); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
$request->validate([ | ||
'ban_type' => 'required|string', | ||
'steamid' => 'required_if:ban_type,Steam ID|nullable|string', | ||
'ip' => 'required_if:ban_type,IP|nullable|ip', | ||
'nickname' => 'required|string', | ||
'comments' => 'required|string', | ||
'name' => 'required|string', | ||
'email' => 'required|email', | ||
'server_id' => 'required|integer', | ||
'media_link' => 'nullable|url', | ||
]); | ||
|
||
$data = $request->only(['ban_type', 'steamid', 'ip', 'nickname', 'comments', 'name', 'email', 'server_id', 'media_link']); | ||
Report::create($data); | ||
|
||
return redirect()->route('reports.create')->with('success', 'Report submitted successfully.'); | ||
} | ||
|
||
public function list() | ||
{ | ||
$reports = Report::orderBy('created_at', 'desc')->get(); | ||
return view('reports.list', compact('reports')); | ||
} | ||
|
||
public function show($id) | ||
{ | ||
$report = Report::findOrFail($id); | ||
return view('reports.show', compact('report')); | ||
} | ||
|
||
public function destroy($id) | ||
{ | ||
$report = Report::findOrFail($id); | ||
$report->delete(); | ||
|
||
return redirect()->route('reports.list')->with('success', 'Report deleted successfully.'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Mail; | ||
|
||
use App\Models\Appeal\Appeal; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Mail\Mailable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class AppealApproved extends Mailable | ||
{ | ||
use Queueable, SerializesModels; | ||
|
||
protected $appeal; | ||
|
||
public function __construct(Appeal $appeal) | ||
{ | ||
$this->appeal = $appeal; | ||
} | ||
|
||
public function build() | ||
{ | ||
return $this->subject('Your Ban Appeal has been'." ".ucfirst($this->appeal->status)) | ||
->view('appeals.email.appeal_status') | ||
->with([ | ||
'appeal' => $this->appeal, | ||
]); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
namespace App\Models\Appeal; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Appeal extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'ban_type', | ||
'steamid', | ||
'name', | ||
'reason', | ||
'email' | ||
]; | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace App\Models\Report; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Report extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'ban_type', | ||
'steamid', | ||
'ip', | ||
'nickname', | ||
'comments', | ||
'name', | ||
'email', | ||
'server_id', | ||
'media_link', | ||
]; | ||
|
||
public function server() | ||
{ | ||
return $this->belongsTo(\App\Models\SaServer::class); | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
database/migrations/2024_06_15_083222_2024_06_14_000000_create_appeals_table.php.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,26 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
class CreateAppealsTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('appeals', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('ban_type'); | ||
$table->string('steamid'); | ||
$table->string('name'); | ||
$table->text('reason'); | ||
$table->string('email'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('appeals'); | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
database/migrations/2024_06_15_142432_2024_06_14_000000_create_reports_table.php.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,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('reports', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('ban_type'); | ||
$table->string('steamid')->nullable(); | ||
$table->ipAddress('ip')->nullable(); | ||
$table->string('nickname'); | ||
$table->text('comments'); | ||
$table->string('name'); | ||
$table->string('email'); | ||
$table->unsignedBigInteger('server_id'); | ||
$table->string('media_link')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('reports'); | ||
} | ||
}; |
Oops, something went wrong.