Added option to disable registration

Added option to disable registration.
This commit is contained in:
JulianPrieber 2022-02-23 20:19:15 +01:00
parent cd47ebb792
commit 4e78b1a58f
8 changed files with 49 additions and 5 deletions

View File

@ -125,7 +125,7 @@ class AdminController extends Controller
//Show site pages to edit
public function showSitePage()
{
$data['pages'] = Page::select('terms', 'privacy', 'contact')->get();
$data['pages'] = Page::select('terms', 'privacy', 'contact', 'register')->get();
return view('panel/pages', $data);
}
@ -135,8 +135,9 @@ class AdminController extends Controller
$terms = $request->terms;
$privacy = $request->privacy;
$contact = $request->contact;
$register = $request->register;
Page::first()->update(['terms' => $terms, 'privacy' => $privacy, 'contact' => $contact]);
Page::first()->update(['terms' => $terms, 'privacy' => $privacy, 'contact' => $contact, 'register' => $register]);
return back();
}

View File

@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Model;
class Page extends Model
{
use HasFactory;
protected $fillable = ['terms', 'privacy', 'contact', 'home_message'];
protected $fillable = ['terms', 'privacy', 'contact', 'register', 'home_message'];
}

11
app/Models/Register.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Register extends Model
{
use HasFactory;
}

View File

@ -19,6 +19,7 @@ class CreatePagesTable extends Migration
$table->text('privacy')->nullable();
$table->text('contact')->nullable();
$table->text('home_message')->nullable();
$table->text('register')->nullable();
$table->timestamps();
});
}

View File

@ -36,6 +36,7 @@ class PageSeeder extends Seeder
themed around customization for the individual users, LittleLink pages.
',
'register' => 'true',
]
];

View File

@ -1,3 +1,11 @@
<?php
$pages = DB::table('pages')->get();
foreach($pages as $page)
{
//Gets value from database
}
?>
<x-guest-layout>
<x-auth-card>
<x-slot name="logo">
@ -5,7 +13,7 @@
<x-application-logo class="w-20 h-20 fill-current text-gray-500" />
</a>
</x-slot>
@if($page->register == 'true')
<!-- Validation Errors -->
<x-auth-validation-errors class="mb-4" :errors="$errors" />
@ -55,5 +63,6 @@
</x-button>
</div>
</form>
@endif
</x-auth-card>
</x-guest-layout>

View File

@ -45,6 +45,15 @@
<!-- end dark mode detection -->
</head>
<body>
<?php
$pages = DB::table('pages')->get();
foreach($pages as $page)
{
//Gets value from database
}
?>
<div class="container">
<div class="row">
<div class="sign" style="margin-top: 30px; text-align: right;">
@ -54,7 +63,7 @@
@else
<a href="{{ route('login') }}" class="underline">Log in</a>
@if (Route::has('register'))
@if (Route::has('register') and $page->register == 'true')
<a href="{{ route('register') }}" class="underline">Register</a>
@endif
@endauth

View File

@ -19,6 +19,18 @@
<label>Contact</label>
<textarea class="form-control" name="contact" rows="3">{{ $page->contact }}</textarea>
</div>
<div class="form-group col-lg-8">
<label for="exampleFormControlSelect1">Allow registration</label>
<select class="form-control" name="register">
@if($page->register == 'true')
<option>true</option>
<option>false</option>
@else
<option>false</option>
<option>true</option>
@endif
</select>
</div>
@endforeach
<button type="submit" class="mt-3 ml-3 btn btn-info">Submit</button>
</form>