From 6ac75efe43654102f25e2dbb060b62db35c6e340 Mon Sep 17 00:00:00 2001 From: armiejean Date: Thu, 1 May 2025 20:19:25 +0800 Subject: [PATCH] integration --- .env.example | 3 + app/Services/ApiService.php | 28 ++-- config/database.php | 6 +- .../0001_01_01_000000_create_users_table.php | 49 ------ .../0001_01_01_000002_create_jobs_table.php | 57 ------- ... 2025_05_01_083709_create_cache_table.php} | 0 docker-compose.yml | 55 ++----- docker/nginx/default.conf | 3 +- package-lock.json | 8 +- package.json | 2 +- public/js/app.js | 2 + .../components/table-component.blade.php | 3 +- resources/views/layouts/app.blade.php | 2 +- resources/views/layouts/login.blade.php | 2 +- resources/views/login.blade.php | 146 ++++++++++++------ .../views/pages/change-password.blade.php | 67 ++++++++ routes/web.php | 6 +- 17 files changed, 227 insertions(+), 212 deletions(-) delete mode 100644 database/migrations/0001_01_01_000000_create_users_table.php delete mode 100644 database/migrations/0001_01_01_000002_create_jobs_table.php rename database/migrations/{0001_01_01_000001_create_cache_table.php => 2025_05_01_083709_create_cache_table.php} (100%) create mode 100644 resources/views/pages/change-password.blade.php diff --git a/.env.example b/.env.example index d260172..ad6e8cf 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,9 @@ APP_DEBUG=true APP_TIMEZONE=UTC APP_URL=http://localhost + + + APP_LOCALE=en APP_FALLBACK_LOCALE=en APP_FAKER_LOCALE=en_US diff --git a/app/Services/ApiService.php b/app/Services/ApiService.php index 2bbe03d..ba5ab19 100644 --- a/app/Services/ApiService.php +++ b/app/Services/ApiService.php @@ -12,7 +12,7 @@ class ApiService public function __construct() { - $this->baseUrl = config('app.api_base_url'); + $this->baseUrl = rtrim(env('API_URL', '/')); } public function fetchData($url, $token = null) @@ -71,16 +71,26 @@ class ApiService } } - public function get($url, $params = []) - { - $token = $this->cookieService->getCookie()['token'] ?? null; - $this->defaultHeaders['Authorization'] = 'Bearer ' . $token; - return $this->makeRequest('get', $url, $params); - } + // public function get($url, $params = []) + // { + // $token = $this->cookieService->getCookie()['token'] ?? null; + // $this->defaultHeaders['Authorization'] = 'Bearer ' . $token; + // return $this->makeRequest('get', $url, $params); + // } - public function post($url, $params = []) +// public function post($url, $params = []) +// { +// return $this->makeRequest('post', $url, $params); +// } + +public function get(string $endpoint, array $query = []) { - return $this->makeRequest('post', $url, $params); + return Http::get("{$this->baseUrl}/{$endpoint}", $data); +} + +public function post(string $endpoint, array $data = []) +{ + return Http::post("{$this->baseUrl}/{$endpoint}", $data); } public function put($url, $params = []) diff --git a/config/database.php b/config/database.php index 90900cb..41a1491 100644 --- a/config/database.php +++ b/config/database.php @@ -47,9 +47,9 @@ return [ 'url' => env('DB_URL'), 'host' => env('DB_HOST', 'db_mysql'), 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'laravel-cms'), - 'username' => env('DB_USERNAME', 'laravel_user'), - 'password' => env('DB_PASSWORD', 'password'), + 'database' => env('DB_DATABASE', 'unioil-app'), + 'username' => env('DB_USERNAME', 'root'), + 'password' => env('DB_PASSWORD', 'secret'), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => env('DB_CHARSET', 'utf8mb4'), 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php deleted file mode 100644 index 05fb5d9..0000000 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ /dev/null @@ -1,49 +0,0 @@ -id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); - - Schema::create('password_reset_tokens', function (Blueprint $table) { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - - Schema::create('sessions', function (Blueprint $table) { - $table->string('id')->primary(); - $table->foreignId('user_id')->nullable()->index(); - $table->string('ip_address', 45)->nullable(); - $table->text('user_agent')->nullable(); - $table->longText('payload'); - $table->integer('last_activity')->index(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('users'); - Schema::dropIfExists('password_reset_tokens'); - Schema::dropIfExists('sessions'); - } -}; diff --git a/database/migrations/0001_01_01_000002_create_jobs_table.php b/database/migrations/0001_01_01_000002_create_jobs_table.php deleted file mode 100644 index 425e705..0000000 --- a/database/migrations/0001_01_01_000002_create_jobs_table.php +++ /dev/null @@ -1,57 +0,0 @@ -id(); - $table->string('queue')->index(); - $table->longText('payload'); - $table->unsignedTinyInteger('attempts'); - $table->unsignedInteger('reserved_at')->nullable(); - $table->unsignedInteger('available_at'); - $table->unsignedInteger('created_at'); - }); - - Schema::create('job_batches', function (Blueprint $table) { - $table->string('id')->primary(); - $table->string('name'); - $table->integer('total_jobs'); - $table->integer('pending_jobs'); - $table->integer('failed_jobs'); - $table->longText('failed_job_ids'); - $table->mediumText('options')->nullable(); - $table->integer('cancelled_at')->nullable(); - $table->integer('created_at'); - $table->integer('finished_at')->nullable(); - }); - - Schema::create('failed_jobs', function (Blueprint $table) { - $table->id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('jobs'); - Schema::dropIfExists('job_batches'); - Schema::dropIfExists('failed_jobs'); - } -}; diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/2025_05_01_083709_create_cache_table.php similarity index 100% rename from database/migrations/0001_01_01_000001_create_cache_table.php rename to database/migrations/2025_05_01_083709_create_cache_table.php diff --git a/docker-compose.yml b/docker-compose.yml index 7400cd5..d9b9a35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,50 +11,31 @@ services: working_dir: /var/www volumes: - .:/var/www - depends_on: - db_mysql: - condition: service_healthy command: > - /bin/sh -c ' - mkdir -p /var/www/storage /var/www/bootstrap/cache && - chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache && - chmod -R 775 /var/www/storage /var/www/bootstrap/cache && - composer install --no-dev --optimize-autoloader && - php artisan migrate --force && - php-fpm ' + /bin/sh -c 'mkdir -p /var/www/storage /var/www/bootstrap/cache && + chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache && + chmod -R 775 /var/www/storage /var/www/bootstrap/cache && + composer install --no-dev --optimize-autoloader && + php-fpm' healthcheck: - test: ["CMD", "sh", "-c", "pgrep php-fpm"] + test: [ "CMD", "sh", "-c", "pgrep php-fpm" ] interval: 30s timeout: 10s retries: 10 networks: - app_network - - # MySQL - db_mysql: - image: mysql:8.0 - container_name: db_mysql - restart: always environment: - MYSQL_ROOT_PASSWORD: newpassword - MYSQL_DATABASE: laravel-cms - MYSQL_USER: laravel_user - MYSQL_PASSWORD: password - MYSQL_ALLOW_EMPTY_PASSWORD: "no" - volumes: - - mysql-data:/var/lib/mysql - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-pnewpassword"] - interval: 10s - timeout: 5s - retries: 5 - networks: - - app_network + - API_URL=http://web:80 + - DB_HOST=db_mysql + - DB_PORT=3306 + - DB_DATABASE=unioil-app + - DB_USERNAME=root + - DB_PASSWORD=secret - # Nginx - web: + # Nginx (renamed to avoid conflict) + nginx-frontend: image: nginx:1.26.3-alpine - container_name: web + container_name: web-app restart: always ports: - "8000:80" @@ -65,16 +46,14 @@ services: app: condition: service_healthy healthcheck: - test: ["CMD", "curl", "-f", "http://localhost"] + test: [ "CMD", "curl", "-f", "http://localhost" ] interval: 30s timeout: 10s retries: 5 networks: - app_network -volumes: - mysql-data: - networks: app_network: + external: true driver: bridge diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf index 843df3b..2fcb85e 100644 --- a/docker/nginx/default.conf +++ b/docker/nginx/default.conf @@ -1,3 +1,4 @@ +# frontend/docker/nginx/default.conf server { listen 80; server_name localhost; @@ -12,7 +13,7 @@ server { location ~ \.php$ { try_files $uri =404; include fastcgi.conf; - fastcgi_pass app:9000; + fastcgi_pass laravel-app:9000; # Matches frontend's 'app' service fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; diff --git a/package-lock.json b/package-lock.json index ae34261..fcb5e83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ }, "devDependencies": { "autoprefixer": "^10.4.20", - "axios": "^1.7.4", + "axios": "^1.9.0", "concurrently": "^9.0.1", "laravel-vite-plugin": "^1.2.0", "postcss": "^8.4.47", @@ -911,9 +911,9 @@ } }, "node_modules/axios": { - "version": "1.8.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz", - "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz", + "integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==", "dev": true, "dependencies": { "follow-redirects": "^1.15.6", diff --git a/package.json b/package.json index 9a8f44e..224b08c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "devDependencies": { "autoprefixer": "^10.4.20", - "axios": "^1.7.4", + "axios": "^1.9.0", "concurrently": "^9.0.1", "laravel-vite-plugin": "^1.2.0", "postcss": "^8.4.47", diff --git a/public/js/app.js b/public/js/app.js index e59d6a0..e986a5d 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1 +1,3 @@ import './bootstrap'; +import axios from 'axios'; +window.axios = axios; // Make axios globally available \ No newline at end of file diff --git a/resources/views/components/table-component.blade.php b/resources/views/components/table-component.blade.php index 577641e..be82f13 100644 --- a/resources/views/components/table-component.blade.php +++ b/resources/views/components/table-component.blade.php @@ -763,4 +763,5 @@ renderTable(); renderPagination(); - \ No newline at end of file + + \ No newline at end of file diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 44a5d86..797ed18 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -297,5 +297,5 @@ }); - + \ No newline at end of file diff --git a/resources/views/layouts/login.blade.php b/resources/views/layouts/login.blade.php index 97ccc48..8e31942 100644 --- a/resources/views/layouts/login.blade.php +++ b/resources/views/layouts/login.blade.php @@ -29,6 +29,6 @@ - + \ No newline at end of file diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php index 71472cc..f44616b 100644 --- a/resources/views/login.blade.php +++ b/resources/views/login.blade.php @@ -1,64 +1,118 @@ +```php @extends('layouts.login') @section('content') -
-
-
+
+
+
+ Unioil Logo - Unioil Logo +
+

Welcome

+ Sign in to continue +
-
-

Welcome

- Sign in to continue + + + +
+
+ +
- -
- +
+ + +
- +
+ - - -
- - +
+
+
+ -
-
- Forgot Username + +
+
+ + + + + @endsection +``` \ No newline at end of file diff --git a/resources/views/pages/change-password.blade.php b/resources/views/pages/change-password.blade.php new file mode 100644 index 0000000..4aa0eb8 --- /dev/null +++ b/resources/views/pages/change-password.blade.php @@ -0,0 +1,67 @@ +@extends('layouts.app') + +@section('content') +
+

Change Password

+ +
+
+ + +
+
+ + +
+ +
+
+ + + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 0d0cea2..761cdf2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -148,4 +148,8 @@ Route::get('/fuel-price-schedule', function () { Route::get('/fuel-price-update-logs', function () { return view('pages.fuel-price-update-logs'); -})->name('fuel-price-update-logs'); \ No newline at end of file +})->name('fuel-price-update-logs'); + +Route::get('/change-password', function () { + return view('pages.change-password'); +})->name('change-password'); \ No newline at end of file