Game-Jaming/Backend/Controllers/Group/SigningUp.php

50 lines
963 B
PHP

<?php
require "../../../bootstrap.php";
use Backend\Models\Group;
use Backend\Models\Password;
use Backend\Models\GameJam;
use Illuminate\Support\Str;
session_start();
$groupName = "";
$errors = array();
if(isset($_POST['reg_group'])){
$group = new Group();
$group->gameJam()->associate(GameJam::find($_POST['gameJamId']));
$group->group_name = $groupName = $_POST['groupName'];
$group->group_amount = $_POST['groupAmount'];
if(!$group->save()){
return;
}
$password = New Password();
$password->group()->associate($group);
$password->password = password_hash($_POST['password'] ,PASSWORD_DEFAULT);
$token = Str::random(100);
$password->remember_token = $token;
if(!$password->save()){
return;
}
$_SESSION['groupName'] = $groupName;
$_SESSION['token'] = $token;
$_SESSION['success'] = "You are now logged in";
header('location: ../../../Frontend/index.php');
}