Skip to content

Commit

Permalink
Merge pull request #7 from toyrik/master
Browse files Browse the repository at this point in the history
Admin UI
  • Loading branch information
toyrik authored Feb 17, 2024
2 parents c2ca733 + 5c0f3ff commit eda114b
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/public/build
/public/hot
/public/storage
/public/robots.txt
/storage/*.key
/vendor
.env
Expand Down
10 changes: 7 additions & 3 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ public function store(Request $request)
$validated = $request->validate([
'username' => ['required', 'string', 'unique:users'],
'email' => ['required', 'string', 'email', 'unique:users'],
'password' => ['required', 'confirmed', 'min:8']
'password' => ['required', 'confirmed', 'min:8'],
'check-bot' => ['nullable'],
]);

if($validated['check-bot']) {
return redirect(RouteServiceProvider::HOME);
}
$user = User::create([
'username' => $request->username,
'email' => $request->email,
'username' => $validated['username'],
'email' => $validated['email'],
'password' => Hash::make($request->password)
]);

Expand Down
27 changes: 27 additions & 0 deletions app/Listeners/UpdateLastLogin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Listeners;

use Carbon\Carbon;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class UpdateLastLogin
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}

/**
* Handle the event.
*/
public function handle(object $event): void
{
$event->user->last_login = Carbon::now();
$event->user->save();
}
}
5 changes: 5 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class EventServiceProvider extends ServiceProvider
Registered::class => [
SendEmailVerificationNotification::class,
],

//Event For Login Details Data
'Illuminate\Auth\Events\Login' => [
'App\Listeners\UpdateLastLogin',
],
];

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->timestamp('last_login')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('last_login');
});
}
};
2 changes: 0 additions & 2 deletions public/robots.txt

This file was deleted.

4 changes: 3 additions & 1 deletion resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
</div>
</form>
<a href="{{ route('password.request') }}" class="text-sm font-medium text-green-600 hover:text-green-500">Сбросить пароль?</a><br>
<a href="{{ route('register') }}" class="text-sm font-medium text-green-600 hover:text-green-500">Зарегистрировать аккаунт</a>
@if(env('APP_ENV') === 'prod')
<a href="{{ route('register') }}" class="text-sm font-medium text-green-600 hover:text-green-500">Зарегистрировать аккаунт</a>
@endif
</div>
</div>
@endsection
7 changes: 7 additions & 0 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
</button>
</div>
</div>
<input
class="d-none"
type="checkbox"
id="check-bot"
name="check-bot"
value="1"
>
</form>
<a href="{{ route('login') }}" class="text-sm font-medium text-green-600 hover:text-green-500">У меня есть аккаунт</a>
</div>
Expand Down
14 changes: 13 additions & 1 deletion resources/views/components/users/list-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
<th style="width: 25%">
Логин
</th>
<th>
Дата активации
</th>
<th>
Дата последнего входа
</th>
</tr>
</thead>
<tbody>
Expand All @@ -21,9 +27,15 @@
</a>
<br>
<small>
{{ $user->created_at }}
Зарегистрирован: {{ $user->created_at }}
</small>
</td>
<td>
{{ $user->email_verified_at }}
</td>
<td>
{{ $user->last_login }}
</td>
</tr>
@endforeach
@else
Expand Down
2 changes: 2 additions & 0 deletions resources/views/layouts/partials/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ class="navbar navbar-white navbar-light navbar-expand main-header">
</div>
</li>
@else
@if(env('APP_ENV') === 'prod')
<li class="nav-item">
<a href="{{ route('register') }}" class="nav-link">Регистрация</a>
</li>
@endif
<li class="nav-item">
<a href="{{ route('login') }}" class="nav-link">Вход</a>
</li>
Expand Down
10 changes: 6 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
Route::get('/', [Controllers\MainController::class, 'index'])->name('home');

Route::middleware('guest')->group(function () {
Route::get('/register', [Controllers\Auth\RegisterController::class, 'create'])
->name('register');
Route::post('/register', [Controllers\Auth\RegisterController::class, 'store'])
->name('membership.create');
if(env('APP_ENV') === 'prod') {
Route::get('/register', [Controllers\Auth\RegisterController::class, 'create'])
->name('register');
Route::post('/register', [Controllers\Auth\RegisterController::class, 'store'])
->name('membership.create');
}

Route::get('/forgot-password', [Controllers\Auth\ForgotPasswordController::class, 'create'])
->name('password.request');
Expand Down

0 comments on commit eda114b

Please sign in to comment.