added AuthController and StaffMember model, update auth config and routes
This commit is contained in:
29
app/Http/Controllers/AuthController.php
Normal file
29
app/Http/Controllers/AuthController.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class AuthController extends Controller
|
||||||
|
{
|
||||||
|
// Your login method is likely here...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the user out of the application.
|
||||||
|
*/
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
// 1. Log the user out
|
||||||
|
Auth::logout();
|
||||||
|
|
||||||
|
// 2. Invalidate the user's session
|
||||||
|
$request->session()->invalidate();
|
||||||
|
|
||||||
|
// 3. Regenerate the CSRF token for security
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
// 4. Redirect them back to the login page
|
||||||
|
return redirect('/login');
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Models/StaffMember.php
Normal file
30
app/Models/StaffMember.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
|
class StaffMember extends Authenticatable
|
||||||
|
{
|
||||||
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
|
// 1. Explicitly define the custom table name
|
||||||
|
protected $table = 'staff_members';
|
||||||
|
|
||||||
|
// 2. Define the fillable fields based on your schema
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
|
// 3. Hide the password from array/JSON conversions
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
// 4. Cast dates correctly
|
||||||
|
protected $casts = [
|
||||||
|
'dob' => 'date',
|
||||||
|
'hire_date' => 'datetime',
|
||||||
|
'password' => 'hashed', // Laravel 10+ password casting
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -62,7 +62,8 @@ return [
|
|||||||
'providers' => [
|
'providers' => [
|
||||||
'users' => [
|
'users' => [
|
||||||
'driver' => 'eloquent',
|
'driver' => 'eloquent',
|
||||||
'model' => env('AUTH_MODEL', App\Models\User::class),
|
// 'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||||
|
'model' => App\Models\StaffMember::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
// 'users' => [
|
// 'users' => [
|
||||||
|
|||||||
@@ -10,13 +10,38 @@
|
|||||||
|
|
||||||
<div class="position-relative me-4">
|
<div class="position-relative me-4">
|
||||||
<i class="bi bi-bell fs-5 text-secondary"></i>
|
<i class="bi bi-bell fs-5 text-secondary"></i>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-flex align-items-center">
|
|
||||||
<div class="rounded-circle bg-light d-flex justify-content-center align-items-center me-2 border text-dark fw-bold" style="width: 32px; height: 32px; font-size: 0.8rem;">
|
|
||||||
{{ substr(auth()->user()->name ?? 'Admin', 0, 1) }}
|
|
||||||
</div>
|
|
||||||
<span class="fw-bold" style="font-size: 0.9rem;">{{ auth()->user()->name ?? 'Admin User' }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- ADDED: Bootstrap Dropdown Wrapper -->
|
||||||
|
<div class="dropdown">
|
||||||
|
<!-- ADDED: dropdown-toggle class, data-bs-toggle attribute, and cursor style -->
|
||||||
|
<div class="d-flex align-items-center dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false" style="cursor: pointer;">
|
||||||
|
<div class="rounded-circle bg-light d-flex justify-content-center align-items-center me-2 border text-dark fw-bold" style="width: 32px; height: 32px; font-size: 0.8rem;">
|
||||||
|
{{ substr(auth()->user()->name ?? 'Admin', 0, 1) }}
|
||||||
|
</div>
|
||||||
|
<span class="fw-bold" style="font-size: 0.9rem;">{{ auth()->user()->name ?? 'Admin User' }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ADDED: Dropdown Menu -->
|
||||||
|
<ul class="dropdown-menu dropdown-menu-end shadow border-light-subtle mt-2">
|
||||||
|
<!-- Profile Link -->
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item d-flex align-items-center py-2" href="{{ url('/profile') }}">
|
||||||
|
<i class="bi bi-person text-secondary me-2 fs-5"></i> My Profile
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li><hr class="dropdown-divider"></li>
|
||||||
|
<!-- Logout Form -->
|
||||||
|
<li>
|
||||||
|
<form action="{{ route('logout') }}" method="POST" class="m-0 p-0">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="dropdown-item d-flex align-items-center py-2 text-danger">
|
||||||
|
<i class="bi bi-box-arrow-right me-2 fs-5"></i> Logout
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -8,28 +8,31 @@ Route::get('test', function () {
|
|||||||
|
|
||||||
Auth::routes();
|
Auth::routes();
|
||||||
|
|
||||||
|
Route::middleware(['auth'])->group(function () {
|
||||||
|
|
||||||
|
Route::get('/', [App\Http\Controllers\DashboardController::class, 'index'])->name('home');
|
||||||
|
Route::get('home', [App\Http\Controllers\DashboardController::class, 'index'])->name('home');
|
||||||
|
|
||||||
Route::get('/', [App\Http\Controllers\DashboardController::class, 'index'])->name('home');
|
Route::get('/clients', [App\Http\Controllers\ClientsController::class, 'index'])->name('clients.index');
|
||||||
|
Route::get('/clients/data', [App\Http\Controllers\ClientsController::class, 'fetchData'])->name('clients.data');
|
||||||
Route::get('/clients', [App\Http\Controllers\ClientsController::class, 'index'])->name('clients.index');
|
Route::get('/clients/export', [App\Http\Controllers\ClientController::class, 'export'])->name('clients.export');
|
||||||
Route::get('/clients/data', [App\Http\Controllers\ClientsController::class, 'fetchData'])->name('clients.data');
|
|
||||||
Route::get('/clients/export', [App\Http\Controllers\ClientController::class, 'export'])->name('clients.export');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Route::get('/staff', [App\Http\Controllers\StaffController::class, 'index'])->name('home');
|
Route::get('/staff', [App\Http\Controllers\StaffController::class, 'index'])->name('home');
|
||||||
|
|
||||||
|
|
||||||
Route::get('/mnos', [App\Http\Controllers\NetworkOperatorsControlle::class, 'index'])->name('mnos.index');
|
Route::get('/mnos', [App\Http\Controllers\NetworkOperatorsControlle::class, 'index'])->name('mnos.index');
|
||||||
Route::get('/documents', [App\Http\Controllers\DocumentsVaultController::class, 'index'])->name('documents.index');
|
Route::get('/documents', [App\Http\Controllers\DocumentsVaultController::class, 'index'])->name('documents.index');
|
||||||
|
|
||||||
Route::get('/senderids', [App\Http\Controllers\SenderidsController::class, 'index']);
|
Route::get('/senderids', [App\Http\Controllers\SenderidsController::class, 'index']);
|
||||||
Route::get('/shortcodes', [App\Http\Controllers\ShortCodesController::class, 'index']);
|
Route::get('/shortcodes', [App\Http\Controllers\ShortCodesController::class, 'index']);
|
||||||
|
|
||||||
|
Route::post('/logout', [App\Http\Controllers\AuthController::class, 'logout'])->name('logout');
|
||||||
|
});
|
||||||
//Aegon-Kingsley Kweku Fenyi Banson
|
//Aegon-Kingsley Kweku Fenyi Banson
|
||||||
//Rhaena Nana Ekua Entsie Banson
|
//Rhaena Nana Ekua Entsie Banson
|
||||||
//Rickon Akyedze Kofi Asare Banson
|
//Rickon Akyedze Kofi Asare Banson
|
||||||
Reference in New Issue
Block a user