diff --git a/app/Http/Controllers/HeadquartersDashboard/LoginToProvinceController.php b/app/Http/Controllers/HeadquartersDashboard/LoginToProvinceController.php index 799ba7f..35bc9c1 100644 --- a/app/Http/Controllers/HeadquartersDashboard/LoginToProvinceController.php +++ b/app/Http/Controllers/HeadquartersDashboard/LoginToProvinceController.php @@ -20,11 +20,13 @@ class LoginToProvinceController extends Controller ->value('ip'); $data = [ - 'user_id' => auth()->user()->id, + 'user_id' => auth()->user()->username, 'token' => Hash::make(config('globalVariables.LOGIN_HASH_VALUE')), 'ip' => $province_ip, ]; + auth()->user()->currentAccessToken()->delete(); + return $this->successResponse($data); } } diff --git a/app/Http/Controllers/ProvinceDashboard/VerifyAuthenticationController.php b/app/Http/Controllers/ProvinceDashboard/VerifyAuthenticationController.php index 92927eb..27c01a7 100644 --- a/app/Http/Controllers/ProvinceDashboard/VerifyAuthenticationController.php +++ b/app/Http/Controllers/ProvinceDashboard/VerifyAuthenticationController.php @@ -19,7 +19,7 @@ class VerifyAuthenticationController extends Controller return $this->errorResponse('Invalid token'); } - $user = User::query()->findOrFail($request->user_id); + $user = User::query()->firstWhere('username', '=', $request->user_id); $token = $user->createToken("{$user->username}", ['*'], now()->addWeek())->plainTextToken; diff --git a/app/Models/Cdr.php b/app/Models/Cdr.php index 50c6c63..95f713c 100644 --- a/app/Models/Cdr.php +++ b/app/Models/Cdr.php @@ -2,9 +2,18 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Storage; class Cdr extends Model { - protected $table = 'cdr'; + protected $table = 'asteriskcdrdb.cdr'; + + protected function recordingfile(): Attribute + { + return Attribute::make( + get: fn($value) => $value == null ? null : url('/') . 'recordingfiles/' . $value + ); + } }