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
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user