can init user and edit prompts
This commit is contained in:
parent
2ad627240f
commit
e84bb44b20
|
|
@ -3,21 +3,28 @@
|
|||
namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Participant;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ParticipantController extends Controller
|
||||
{
|
||||
public function createFromToken(Request $request, string $id)
|
||||
public static function createFromToken(Request $request, string $id)
|
||||
{
|
||||
if ($request->input('password') !== env('ADMIN__PASSWORD')) {
|
||||
if ($request->input('password') !== 'password123') {
|
||||
return response()->json(['message' => 'Unauthorized: Wrong password'], 401);
|
||||
}
|
||||
|
||||
$participant = Participant::create([
|
||||
'user_id' => $id,
|
||||
'token' => (string) Str::ulid()
|
||||
]);
|
||||
if(!Participant::where('id', $id)->exists()) {
|
||||
$participant = Participant::create([
|
||||
'user_id' => $id,
|
||||
'token' => (string) Str::ulid()
|
||||
]);
|
||||
|
||||
return $participant->token;
|
||||
return $participant->token;
|
||||
}
|
||||
else {
|
||||
$participant = Participant::where('id', $id)->first();
|
||||
return $participant->token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Illuminate\Foundation\Configuration\Middleware;
|
|||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ class ParticipantFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => fake()->unique()->randomNumber(),
|
||||
'token' => (string) Str::ulid(),
|
||||
'user_id' => fake()->unique()->randomNumber(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Database\Seeders;
|
|||
|
||||
use App\Models\Participant;
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Eloquent\Factories\Sequence;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
|
|
@ -14,7 +14,11 @@ class DatabaseSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Participant::factory(10)->create();
|
||||
|
||||
Participant::factory(100)
|
||||
->sequence(fn (Sequence $sequence) => [
|
||||
'id' => $sequence->index + 1,
|
||||
'user_id' => $sequence->index + 1,
|
||||
])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\ParticipantController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::post('/token/{id}', [ParticipantController::class, 'createFromToken']);
|
||||
|
||||
|
|
@ -1,15 +1,8 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Laravel\Fortify\Features;
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
Route::middleware(['santa'])->group(function () {
|
||||
Route::get('/token/{id}', function ($id) {
|
||||
return $id; // todo return the token from participant auth controller
|
||||
});
|
||||
});
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
})->name('home');
|
||||
|
|
@ -17,7 +10,3 @@ Route::get('/', function () {
|
|||
Volt::route('start', 'pages.start')->name('start');
|
||||
Volt::route('profile/{token}', 'pages.profile')->name('profile');
|
||||
Volt::route('withdraw', 'pages.withdraw')->name('withdraw');
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue