Skip to content

Commit 4e78b1a

Browse files
committed
Added option to disable registration
Added option to disable registration.
1 parent cd47ebb commit 4e78b1a

File tree

8 files changed

+49
-5
lines changed

8 files changed

+49
-5
lines changed

app/Http/Controllers/AdminController.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function editUser(request $request)
125125
//Show site pages to edit
126126
public function showSitePage()
127127
{
128-
$data['pages'] = Page::select('terms', 'privacy', 'contact')->get();
128+
$data['pages'] = Page::select('terms', 'privacy', 'contact', 'register')->get();
129129
return view('panel/pages', $data);
130130
}
131131

@@ -135,8 +135,9 @@ public function editSitePage(request $request)
135135
$terms = $request->terms;
136136
$privacy = $request->privacy;
137137
$contact = $request->contact;
138+
$register = $request->register;
138139

139-
Page::first()->update(['terms' => $terms, 'privacy' => $privacy, 'contact' => $contact]);
140+
Page::first()->update(['terms' => $terms, 'privacy' => $privacy, 'contact' => $contact, 'register' => $register]);
140141

141142
return back();
142143
}

app/Models/Page.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
class Page extends Model
99
{
1010
use HasFactory;
11-
protected $fillable = ['terms', 'privacy', 'contact', 'home_message'];
11+
protected $fillable = ['terms', 'privacy', 'contact', 'register', 'home_message'];
1212
}

app/Models/Register.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Register extends Model
9+
{
10+
use HasFactory;
11+
}

database/migrations/2021_03_18_082232_create_pages_table.php

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function up()
1919
$table->text('privacy')->nullable();
2020
$table->text('contact')->nullable();
2121
$table->text('home_message')->nullable();
22+
$table->text('register')->nullable();
2223
$table->timestamps();
2324
});
2425
}

database/seeders/PageSeeder.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function run()
3636
themed around customization for the individual users, LittleLink pages.
3737
',
3838

39+
'register' => 'true',
3940
]
4041
];
4142

resources/views/auth/register.blade.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
<?php
2+
$pages = DB::table('pages')->get();
3+
foreach($pages as $page)
4+
{
5+
//Gets value from database
6+
}
7+
?>
8+
19
<x-guest-layout>
210
<x-auth-card>
311
<x-slot name="logo">
412
<a href="{{ config('app.url') }}">
513
<x-application-logo class="w-20 h-20 fill-current text-gray-500" />
614
</a>
715
</x-slot>
8-
16+
@if($page->register == 'true')
917
<!-- Validation Errors -->
1018
<x-auth-validation-errors class="mb-4" :errors="$errors" />
1119

@@ -55,5 +63,6 @@
5563
</x-button>
5664
</div>
5765
</form>
66+
@endif
5867
</x-auth-card>
5968
</x-guest-layout>

resources/views/home.blade.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ function update_color_scheme() {
4545
<!-- end dark mode detection -->
4646
</head>
4747
<body>
48+
49+
<?php
50+
$pages = DB::table('pages')->get();
51+
foreach($pages as $page)
52+
{
53+
//Gets value from database
54+
}
55+
?>
56+
4857
<div class="container">
4958
<div class="row">
5059
<div class="sign" style="margin-top: 30px; text-align: right;">
@@ -54,7 +63,7 @@ function update_color_scheme() {
5463
@else
5564
<a href="{{ route('login') }}" class="underline">Log in</a>
5665

57-
@if (Route::has('register'))
66+
@if (Route::has('register') and $page->register == 'true')
5867
<a href="{{ route('register') }}" class="underline">Register</a>
5968
@endif
6069
@endauth

resources/views/panel/pages.blade.php

+12
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
<label>Contact</label>
2020
<textarea class="form-control" name="contact" rows="3">{{ $page->contact }}</textarea>
2121
</div>
22+
<div class="form-group col-lg-8">
23+
<label for="exampleFormControlSelect1">Allow registration</label>
24+
<select class="form-control" name="register">
25+
@if($page->register == 'true')
26+
<option>true</option>
27+
<option>false</option>
28+
@else
29+
<option>false</option>
30+
<option>true</option>
31+
@endif
32+
</select>
33+
</div>
2234
@endforeach
2335
<button type="submit" class="mt-3 ml-3 btn btn-info">Submit</button>
2436
</form>

0 commit comments

Comments
 (0)