Hey all, newbie here
I apologize for the cryptic title, I'm new to Laravel and PHP.
I'm building a CTF application using Laravel Jetstream with LiveWire as part of a university project.
Users will submit flags they've found, and I want that data to be compared with a database entry.
If they flag is correct, I want this to be shown:
<span
class="inline-flex px-2 text-xs font-semibold leading-5 text-green-800 bg-green-100 rounded-full">
Flag Correct!
</span>
If they got it wrong, I want this to be displayed:
<span
class="inline-flex px-2 text-xs font-semibold leading-5 text-red-800 bg-red-100 rounded-full">
Flag Incorrect
</span>
I have most of this code in place, but I'm not sure how to get the logic or routes to work with LiveWire.
I have a controller, FlagVerification that has some of the logic, but I'm mainly stuck on how to move this information between the controller and the view, and how to use LiveWire to update what the user sees
Here's my controller so far:
<?php
namespace App\Http\Controllers;
use App\Models\Flag;
class FlagVerification extends Controller
{
function VerifyFlags()
{
// Get first flag from db
$flag1 = Flag::where('id', 1)->value('flags');
// Compare User input with $flag1
// TODO: Pass whatever user entered from table to controller?
if ($flag1 == 'OBR{1FA528F41E8945C}') {
return $flag1;
// If User entered wrong flag, update view.
} else {
// Manipulate table to show "incorrect flag"
return 'Incorrect Flag';
}
}
}
This is what the frontend looks like, it might help give a better idea of the goal imgur[.]com/a/U8ItJuT
I realise this is a lot to ask, so any pointers or tips would be really appreciated
Thank you!