From 67efae2875f11350b33b493c060bd3aa56feda01 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Sun, 4 May 2025 12:58:18 +0330 Subject: [PATCH] change migration name --- docker-compose.yml | 12 ++++++------ laravel/app/Http/Controllers/CallController.php | 13 +++++++++---- laravel/app/Http/Requests/Call/StoreRequest.php | 4 ++-- laravel/bootstrap/app.php | 2 +- .../2025_04_29_113931_create_categories_table.php | 2 -- ...hp => 2025_04_29_120015_create_events_table.php} | 0 ...025_04_29_125524_create_call_histories_table.php | 9 ++------- 7 files changed, 20 insertions(+), 22 deletions(-) rename laravel/database/migrations/{2025_04_29_130015_create_events_table.php => 2025_04_29_120015_create_events_table.php} (100%) diff --git a/docker-compose.yml b/docker-compose.yml index 1498951..bf26c88 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,9 +21,9 @@ services: ports: - "8070:5432" environment: - POSTGRES_DB: ${NOTIFICATION_DB} - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${NOTIFICATION_SERVER_DB} + POSTGRES_USER: ${NOTIFICATION_SERVER_USER} + POSTGRES_PASSWORD: ${NOTIFICATION_SERVER_PASSWORD} volumes: - ./notification:/var/lib/postgresql/data profiles: @@ -49,7 +49,7 @@ services: networks: - notification depends_on: - - postgres + - backend_db notification_server: build: @@ -67,7 +67,7 @@ services: - DB_SYNC=${NOTIFICATION_SERVER_DB_SYNC} - PORT=${NOTIFICATION_SERVER_PORT} ports: - - "3023:3023" + - "3023:${NOTIFICATION_SERVER_PORT}" volumes: - ${NOTIFICATION_SERVER_PATH}:/var/www/crm-notification-server profiles: @@ -75,7 +75,7 @@ services: networks: - notification depends_on: - - backend-db + - backend_db - laravel - notification_db diff --git a/laravel/app/Http/Controllers/CallController.php b/laravel/app/Http/Controllers/CallController.php index becb317..58a0b64 100644 --- a/laravel/app/Http/Controllers/CallController.php +++ b/laravel/app/Http/Controllers/CallController.php @@ -25,17 +25,22 @@ class CallController extends Controller { use ApiResponse; - public function store(StoreRequest $request,NotificationService $notificationService): JsonResponse + /** + * @throws OperatorNotConnectedException + * @throws OperatorOfflineException + * @throws NotificationServerNotRespondingException + */ + public function store(StoreRequest $request, NotificationService $notificationService): JsonResponse { try { $call = DB::transaction(function () use ($request) { - $operator = User::query()->where('telephone_id', $request->telephone_id)->first(); + $operator = User::query()->where('telephone_id', $request->extension)->first(); $call = Call::query()->create([ - 'telephone_id' => $request->telephone_id, - 'caller_phone_number' => $request->caller_phone_number, + 'telephone_id' => $request->extension, + 'caller_phone_number' => $request->caller_id, 'operator_id' => $operator->id, 'operator_username' => $operator->username, 'operator_full_name' => $operator->full_name diff --git a/laravel/app/Http/Requests/Call/StoreRequest.php b/laravel/app/Http/Requests/Call/StoreRequest.php index 2d47c25..9815bfd 100644 --- a/laravel/app/Http/Requests/Call/StoreRequest.php +++ b/laravel/app/Http/Requests/Call/StoreRequest.php @@ -23,8 +23,8 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'telephone_id' => 'required|string|exists:users,telephone_id', - 'caller_phone_number' => 'required|numeric|regex:/^09\d{9}$/', + 'extension' => 'required|string|exists:users,telephone_id', + 'caller_id' => 'required|numeric|regex:/^09\d{9}$/', ]; } } diff --git a/laravel/bootstrap/app.php b/laravel/bootstrap/app.php index 6178ce8..87267b9 100644 --- a/laravel/bootstrap/app.php +++ b/laravel/bootstrap/app.php @@ -13,7 +13,7 @@ return Application::configure(basePath: dirname(__DIR__)) ) ->withMiddleware(function (Middleware $middleware) { $middleware->validateCsrfTokens(except: [ - '/auth/login' // <-- exclude this route + '*' ]); $middleware->statefulApi(); }) diff --git a/laravel/database/migrations/2025_04_29_113931_create_categories_table.php b/laravel/database/migrations/2025_04_29_113931_create_categories_table.php index 6ba142c..d21ce0f 100644 --- a/laravel/database/migrations/2025_04_29_113931_create_categories_table.php +++ b/laravel/database/migrations/2025_04_29_113931_create_categories_table.php @@ -15,10 +15,8 @@ return new class extends Migration $table->id(); $table->unsignedSmallInteger('category_id'); $table->string('category_name'); - $table->unsignedSmallInteger('subcategory_id')->nullable(); $table->string('subcategory_name')->nullable(); - $table->timestamps(); }); } diff --git a/laravel/database/migrations/2025_04_29_130015_create_events_table.php b/laravel/database/migrations/2025_04_29_120015_create_events_table.php similarity index 100% rename from laravel/database/migrations/2025_04_29_130015_create_events_table.php rename to laravel/database/migrations/2025_04_29_120015_create_events_table.php diff --git a/laravel/database/migrations/2025_04_29_125524_create_call_histories_table.php b/laravel/database/migrations/2025_04_29_125524_create_call_histories_table.php index 1a6c7ec..fd78cb2 100644 --- a/laravel/database/migrations/2025_04_29_125524_create_call_histories_table.php +++ b/laravel/database/migrations/2025_04_29_125524_create_call_histories_table.php @@ -13,16 +13,11 @@ return new class extends Migration { Schema::create('call_histories', function (Blueprint $table) { $table->id(); - $table->foreignId('call_id') - ->constrained('calls'); - + $table->foreignId('call_id')->constrained('calls'); $table->string('telephone_id'); $table->string('caller_phone_number'); - - $table->foreignId('event_id') - ->constrained(); + $table->foreignId('event_id')->constrained('events'); $table->string('event_name'); - $table->timestamps(); }); }