Now keeping last user connection date

This commit is contained in:
Axel 2023-05-25 16:08:56 +02:00
parent 2fed92653f
commit 7fa06d74fd
Signed by: axel
GPG key ID: 73C0A5961B6BC740
2 changed files with 9 additions and 0 deletions

View file

@ -6,6 +6,7 @@ use Exception;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use App\Models\User; use App\Models\User;
use Carbon\Carbon;
class Auth { class Auth {
@ -35,6 +36,10 @@ class Auth {
// OK, user's credentials are OK // OK, user's credentials are OK
session()->put('username', $username); session()->put('username', $username);
session()->put('authenticated', true); session()->put('authenticated', true);
$user->connected_at = Carbon::now();
$user->save();
return true; return true;
} }
catch (Exception $e) { catch (Exception $e) {

View file

@ -32,6 +32,9 @@ class User extends Authenticatable
'password', 'password',
]; ];
protected $casts = [
'connected_at' => 'datetime',
];
public $incrementing = false; public $incrementing = false;
@ -50,6 +53,7 @@ class User extends Authenticatable
{ {
$table->string('username'); $table->string('username');
$table->string('password'); $table->string('password');
$table->timestamp('connected_at')->nullable();
} }
public function bundles() { public function bundles() {