|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
namespace App\Http\Controllers; |
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
|
|
use App\Http\Resources\UserResource; |
|
|
use App\Models\Business; |
|
|
use App\Models\Business; |
|
|
use App\Models\User; |
|
|
use App\Models\User; |
|
|
use App\Notifications\DBNotification; |
|
|
use App\Notifications\DBNotification; |
|
@ -279,4 +280,34 @@ class AuthController extends Controller |
|
|
])); |
|
|
])); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function auth() |
|
|
|
|
|
{ |
|
|
|
|
|
return new UserResource(Auth::user()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function authWithInfo() |
|
|
|
|
|
{ |
|
|
|
|
|
return [ |
|
|
|
|
|
'auth' => new UserResource(Auth::user()), |
|
|
|
|
|
'businesses' => Auth::user()->businesses->keyBy('id') ->map(fn($b, $bid) => Business::info($bid)) |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function updateFcmToken(Request $request) |
|
|
|
|
|
{ |
|
|
|
|
|
Auth::user()->fingerprints()->where( |
|
|
|
|
|
[ |
|
|
|
|
|
['agent', request()->getAgent()], |
|
|
|
|
|
['ip', request()->getClientIp()], |
|
|
|
|
|
['os', request()->getOS()], |
|
|
|
|
|
['latitude', \request()->getLocation()->getAttribute('lat')], |
|
|
|
|
|
['longitude', \request()->getLocation()->getAttribute('lon')], |
|
|
|
|
|
] |
|
|
|
|
|
)->firstOrFail()->update([ |
|
|
|
|
|
'fcm_token' => $request->fcm_token |
|
|
|
|
|
]); |
|
|
|
|
|
return $this->authWithInfo(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |