Skip to content

Commit

Permalink
Added option to disable registration
Browse files Browse the repository at this point in the history
Added option to disable registration.
  • Loading branch information
JulianPrieber committed Feb 23, 2022
1 parent cd47ebb commit 4e78b1a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function editUser(request $request)
//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);
}

Expand All @@ -135,8 +135,9 @@ public function editSitePage(request $request)
$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();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
class Page extends Model
{
use HasFactory;
protected $fillable = ['terms', 'privacy', 'contact', 'home_message'];
protected $fillable = ['terms', 'privacy', 'contact', 'register', 'home_message'];
}
11 changes: 11 additions & 0 deletions app/Models/Register.php
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function up()
$table->text('privacy')->nullable();
$table->text('contact')->nullable();
$table->text('home_message')->nullable();
$table->text('register')->nullable();
$table->timestamps();
});
}
Expand Down
1 change: 1 addition & 0 deletions database/seeders/PageSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function run()
themed around customization for the individual users, LittleLink pages.
',

'register' => 'true',
]
];

Expand Down
11 changes: 10 additions & 1 deletion resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<?php
$pages = DB::table('pages')->get();
foreach($pages as $page)
{
//Gets value from database
}
?>

<x-guest-layout>
<x-auth-card>
<x-slot name="logo">
<a href="{{ config('app.url') }}">
<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" />

Expand Down Expand Up @@ -55,5 +63,6 @@
</x-button>
</div>
</form>
@endif
</x-auth-card>
</x-guest-layout>
11 changes: 10 additions & 1 deletion resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ function update_color_scheme() {
<!-- 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;">
Expand All @@ -54,7 +63,7 @@ function update_color_scheme() {
@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
Expand Down
12 changes: 12 additions & 0 deletions resources/views/panel/pages.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 4e78b1a

Please sign in to comment.