pixelfed/app/Listeners/AuthLogin.php

41 lines
716 B
PHP
Raw Normal View History

2018-07-23 17:29:20 +00:00
<?php
2018-09-16 00:36:04 +00:00
namespace App\Listeners;
2018-07-23 17:29:20 +00:00
2018-10-24 18:41:14 +00:00
use DB;
2018-08-28 03:07:36 +00:00
use App\User;
use App\UserSetting;
2018-09-16 00:36:04 +00:00
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
2018-07-23 17:29:20 +00:00
2018-09-16 00:36:04 +00:00
class AuthLogin
2018-07-23 17:29:20 +00:00
{
/**
2018-09-16 00:36:04 +00:00
* Create the event listener.
2018-07-23 17:29:20 +00:00
*
* @return void
*/
public function __construct()
{
//
}
2018-09-16 00:36:04 +00:00
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle($event)
2018-07-23 17:29:20 +00:00
{
2018-09-16 00:36:04 +00:00
$user = $event->user;
2018-08-28 03:07:36 +00:00
if (empty($user->settings)) {
2018-10-24 18:41:14 +00:00
DB::transaction(function() use($user) {
UserSetting::firstOrCreate([
'user_id' => $user->id
]);
});
2018-07-23 17:29:20 +00:00
}
}
}