Compare commits

..

1 Commits

Author SHA1 Message Date
ccd2de26df Merge pull request 'install fresh laravel 13' (#1) from develop into main
Reviewed-on: #1
2026-04-26 11:55:45 +00:00
49 changed files with 130 additions and 2094 deletions

View File

@@ -1,36 +1,28 @@
FROM php:8.5.3-fpm-alpine3.23
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie
# Install common PHP extension dependencies
RUN apk update && apk add --no-cache \
bash \
curl \
libpng \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libwebp-dev \
libxml2-dev \
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev \
unzip \
libzip-dev \
libpq-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install pdo_pgsql gd zip
zip \
&& install-php-extensions pdo_pgsql pgsql \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /var/www/payment
#ENV SERVER_NAME=your-domain-name.example.com
# Copy Laravel application
COPY . .
RUN chmod -R 775 /var/www/payment/storage /var/www/payment/bootstrap/cache
# Give permissions to storage and bootstrap/cache
RUN chmod -R 777 storage bootstrap/cache
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER=1
COPY --from=docker.arvancloud.ir/composer:latest /usr/bin/composer /usr/bin/composer
# Default command
CMD composer install;\
composer dump-autoload --optimize --classmap-authoritative ;\
php artisan key:generate;\
php artisan migrate;\
php artisan db:seed;\
php-fpm
frankenphp php-server -r public/

View File

@@ -14,28 +14,19 @@ COPY . .
RUN composer dump-autoload --optimize --classmap-authoritative
FROM php:8.5.3-fpm-alpine3.23 AS application
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie AS application
RUN apk update && apk add --no-cache \
bash \
curl \
libpng \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libwebp-dev \
libxml2-dev \
unzip \
libzip-dev \
libpq-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install pdo_pgsql gd zip
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev unzip zip \
&& install-php-extensions pdo_pgsql pgsql \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/payment
COPY --from=builder /app /var/www/payment
RUN chown -R www-data:www-data /var/www/payment \
&& chmod -R 665 storage bootstrap/cache
&& chmod -R 775 storage bootstrap/cache
CMD ["php-fpm"]
CMD ["frankenphp", "php-server", "-r", "public/"]

22
backend/app/Models/User.php Executable file → Normal file
View File

@@ -5,18 +5,28 @@ namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
#[Guarded(['id'])]
#[Hidden(['password'])]
#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable, HasApiTokens;
protected $guarded = ['id'];
use HasFactory, Notifiable;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

5
backend/app/Providers/AppServiceProvider.php Executable file → Normal file
View File

@@ -3,8 +3,6 @@
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Passport;
use Carbon\CarbonInterval;
class AppServiceProvider extends ServiceProvider
{
@@ -21,7 +19,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
Passport::enablePasswordGrant();
Passport::personalAccessTokensExpireIn(CarbonInterval::minutes(1));
//
}
}

View File

@@ -1,31 +0,0 @@
<?php
namespace App\Traits;
use Illuminate\Http\JsonResponse;
trait ApiResponse
{
public function successResponse(mixed $data = null, string $message = null, int $statusCode = 200): JsonResponse
{
if (!is_null($data)) {
return response()->json([
'data' => $data
], $statusCode);
}
$message = $message ?? __('messages.successful');
return response()->json([
'message' => $message
], $statusCode);
}
public function errorResponse(string $message, string $type = 'logical_exception', int $statusCode = 422): JsonResponse
{
return response()->json([
'type' => $type,
'message' => $message
], $statusCode);
}
}

View File

@@ -1,65 +0,0 @@
<?php
namespace App\User\Controller\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Traits\ApiResponse;
use App\User\Requests\Auth\LoginRequest;
use App\User\Requests\Auth\RegisterRequest;
use App\User\Resources\UserResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class AuthController extends Controller
{
use ApiResponse;
public function register(RegisterRequest $request): JsonResponse
{
User::query()->create([
'username' => $request->username,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
$request->session()->regenerate();
return $this->successResponse();
}
public function login(LoginRequest $request): JsonResponse
{
$credentials = ['password' => $request->password,];
if (filter_var($request->login, FILTER_VALIDATE_EMAIL)) {
$credentials['email'] = $request->login;
} else {
$credentials['username'] = $request->login;
}
if (Auth::attempt($credentials))
{
$request->session()->regenerate();
$user = Auth::user();
return $this->successResponse(new UserResource($user));
}
return $this->errorResponse(__('messages.incorrect_or_username_password'));
}
public function logout(Request $request): JsonResponse
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return $this->successResponse();
}
}

View File

@@ -1,56 +0,0 @@
<?php
namespace App\User\Controller;
use App\Http\Controllers\Controller;
use App\Traits\ApiResponse;
use App\User\Requests\Profile\ChangePasswordRequest;
use App\User\Requests\Profile\EditRequest;
use App\User\Resources\UserResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class ProfileController extends Controller
{
use ApiResponse;
public function info(): JsonResponse
{
return $this->successResponse(new UserResource(Auth::user()));
}
public function edit(EditRequest $request): JsonResponse
{
$user = Auth::user();
$user->update([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'national_id' => $request->national_id,
'address' => $request->address,
'postal_code' => $request->postal_code,
'account_number' => $request->account_number,
'phone_number' => $request->phone_number,
'province_id' => $request->province_id,
'city_id' => $request->city_id,
]);
return $this->successResponse();
}
public function changePassword(ChangePasswordRequest $request): JsonResponse
{
$user = Auth::user();
if (! Hash::check($request->current_password, $user->password)) {
return $this->errorResponse(__('messages.incorrect_current_password'));
}
$user->update([
'password' => Hash::make($request->new_password),
]);
return $this->successResponse();
}
}

View File

@@ -1,29 +0,0 @@
<?php
namespace App\User\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'login' => 'required|string',
'password' => 'required|string',
];
}
}

View File

@@ -1,30 +0,0 @@
<?php
namespace App\User\Requests\Auth;
use Illuminate\Foundation\Http\FormRequest;
class RegisterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'username' => 'required|unique:users,username',
'email' => 'required|email|unique:users,email',
'password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6|confirmed:',
];
}
}

View File

@@ -1,30 +0,0 @@
<?php
namespace App\User\Requests\Profile;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class ChangePasswordRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [
'current_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6',
'new_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6',
];
}
}

View File

@@ -1,37 +0,0 @@
<?php
namespace App\User\Requests\Profile;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class EditRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
return [
'first_name' => 'required|string',
'last_name' => 'required|string',
'national_id' => 'required',
'address' => 'required',
'postal_code' => 'required',
'account_number' => 'required',
'phone_number' => 'required|regex:/^964\d{9}$/|numeric|digits:11',
'province_id' => 'required',
'city_id' => 'required',
];
}
}

View File

@@ -1,23 +0,0 @@
<?php
namespace App\User\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class UserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'username' => $this->username,
'email' => $this->email,
];
}
}

View File

@@ -1,62 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class AuthorizationService
{
protected string $url;
protected string $channelName;
protected array $inputParameters;
public function __construct()
{
$this->url = config('fib.authorization.url');
$this->channelName = '';
}
public function setInputParameters(): void
{
$this->inputParameters = [
'client_id' => config('fib.authorization.client_id'),
'client_secret' => config('fib.authorization.client_secret'),
'grant_type' => 'client_credentials',
];
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders(['Content-Type' => 'application/json'])
->throw()
->withoutVerifying()
->post($this->url, $this->inputParameters)
->json();
}
}

View File

@@ -1,62 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class CancelPaymentService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
public function __construct()
{
$this->url = config('fib.cancelPayment.url');
$this->channelName = '';
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
->throw()
->withoutVerifying()
->post($this->url)
->json();
}
}

View File

@@ -1,51 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class CheckPaymentStatusService
{
protected string $url;
protected string $channelName;
public function __construct()
{
$this->url = config('fib.checkPaymentStatus.url');
$this->channelName = '';
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::throw()
->withoutVerifying()
->post($this->url)
->json();
}
}

View File

@@ -1,73 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class CreatePaymentService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
protected array $inputParameters;
public function __construct()
{
$this->url = config('fib.createPayment.url');
$this->channelName = '';
}
public function setAccessToken(string $accessToken): void
{
$this->accessToken = $accessToken;
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
}
public function setInputParameters(array $inputParameters): void
{
$this->inputParameters = $inputParameters;
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
->throw()
->withoutVerifying()
->post($this->url, $this->inputParameters)
->json();
}
}

View File

@@ -1,62 +0,0 @@
<?php
namespace App\User\Services\FIB;
use Exception;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class RefundService
{
protected string $url;
protected string $channelName;
protected string $accessToken;
protected array $headers;
public function __construct()
{
$this->url = config('fib.refund.url');
$this->channelName = '';
}
public function setHeaders(): void
{
$this->headers = [
'Authorization' => 'Bearer ' . $this->accessToken,
'Content-Type' => 'application/json',
];
}
/**
* @throws Exception
*/
public function run(): array
{
try {
return $this->sendRequest();
}
catch (Exception $e) {
Log::channel($this->channelName)
->error(get_class($this),
[
'message' => $e->getMessage(),
]
);
throw $e;
}
}
/**
* @throws ConnectionException
*/
public function sendRequest(): array
{
return Http::withHeaders($this->headers)
->throw()
->withoutVerifying()
->post($this->url)
->json();
}
}

3
backend/bootstrap/app.php Executable file → Normal file
View File

@@ -7,12 +7,11 @@ use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->web()->validateCsrfTokens(['*']);
//
})
->withExceptions(function (Exceptions $exceptions): void {
//

0
backend/bootstrap/cache/.gitignore vendored Executable file → Normal file
View File

View File

@@ -11,7 +11,6 @@
"require": {
"php": "^8.3",
"laravel/framework": "^13.0",
"laravel/passport": "^13.0",
"laravel/tinker": "^3.0"
},
"require-dev": {

1010
backend/composer.lock generated

File diff suppressed because it is too large Load Diff

4
backend/config/auth.php Executable file → Normal file
View File

@@ -42,10 +42,6 @@ return [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
/*

View File

@@ -1,34 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['*'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => true,
];

View File

@@ -1,25 +0,0 @@
<?php
return [
'authorization' => [
'url' => env('FIB_AUTHORIZATION_URL'),
'client_id' => env('FIB_CLIENT_ID'),
'client_secret' => env('FIB_CLIENT_SECRET'),
],
'createPayment' => [
'url' => env('FIB_CREATE_PAYMENT_URL'),
],
'checkPaymentStatus' => [
'url' => env('FIB_CHECK_PAYMENT_STATUS_URL'),
],
'cancelPayment' => [
'url' => env('FIB_CANCEL_PAYMENT_URL'),
],
'refund' => [
'url' => env('FIB_REFUND_URL'),
],
];

View File

@@ -1,48 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Passport Guard
|--------------------------------------------------------------------------
|
| Here you may specify which authentication guard Passport will use when
| authenticating users. This value should correspond with one of your
| guards that is already present in your "auth" configuration file.
|
*/
'guard' => 'web',
'middleware' => [],
/*
|--------------------------------------------------------------------------
| Encryption Keys
|--------------------------------------------------------------------------
|
| Passport uses encryption keys while generating secure access tokens for
| your application. By default, the keys are stored as local files but
| can be set via environment variables when that is more convenient.
|
*/
'private_key' => env('PASSPORT_PRIVATE_KEY'),
'public_key' => env('PASSPORT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Passport Database Connection
|--------------------------------------------------------------------------
|
| By default, Passport's models will utilize your application's default
| database connection. If you wish to use a different connection you
| may specify the configured name of the database connection here.
|
*/
'connection' => env('PASSPORT_CONNECTION'),
];

0
backend/config/session.php Executable file → Normal file
View File

2
backend/database/factories/UserFactory.php Executable file → Normal file
View File

@@ -25,7 +25,7 @@ class UserFactory extends Factory
public function definition(): array
{
return [
'username' => fake()->name(),
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),

View File

@@ -13,25 +13,20 @@ return new class extends Migration
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('username');
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->tinyInteger('status')->default(0);
$table->string('national_id')->nullable();
$table->string('address')->nullable();
$table->string('postal_code')->nullable();
$table->string('account_number')->nullable();
$table->string('phone_number')->nullable();
$table->string('province_id')->nullable();
$table->string('province_name')->nullable();
$table->string('city_id')->nullable();
$table->string('city_name')->nullable();
$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();
@@ -48,6 +43,7 @@ return new class extends Migration
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};

View File

@@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('oauth_auth_codes', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->foreignId('user_id')->index();
$table->foreignUuid('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_auth_codes');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,41 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('oauth_access_tokens', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->foreignId('user_id')->nullable()->index();
$table->foreignUuid('client_id');
$table->string('name')->nullable();
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->timestamps();
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_access_tokens');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->char('access_token_id', 80)->index();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_refresh_tokens');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('oauth_clients', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->nullableMorphs('owner');
$table->string('name');
$table->string('secret')->nullable();
$table->string('provider')->nullable();
$table->text('redirect_uris');
$table->text('grant_types');
$table->boolean('revoked');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_clients');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

View File

@@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('oauth_device_codes', function (Blueprint $table) {
$table->char('id', 80)->primary();
$table->foreignId('user_id')->nullable()->index();
$table->foreignUuid('client_id')->index();
$table->char('user_code', 8)->unique();
$table->text('scopes');
$table->boolean('revoked');
$table->dateTime('user_approved_at')->nullable();
$table->dateTime('last_polled_at')->nullable();
$table->dateTime('expires_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('oauth_device_codes');
}
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return $this->connection ?? config('passport.connection');
}
};

3
backend/database/seeders/DatabaseSeeder.php Executable file → Normal file
View File

@@ -18,9 +18,8 @@ class DatabaseSeeder extends Seeder
// User::factory(10)->create();
User::factory()->create([
'username' => 'Test User',
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'password123@',
]);
}
}

View File

@@ -1,10 +0,0 @@
<?php
use App\User\Controller\Auth\AuthController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:api');

21
backend/routes/web.php Executable file → Normal file
View File

@@ -1,24 +1,7 @@
<?php
use App\User\Controller\Auth\AuthController;
use App\User\Controller\ProfileController;
use Illuminate\Support\Facades\Route;
Route::prefix('auth')
->name('Auth.')
->controller(AuthController::class)
->group(function () {
Route::post('register', 'register')->name('register');
Route::post('login', 'login')->name('login');
Route::post('logout', 'logout')->name('logout');
});
Route::prefix('profile')
->name('profile.')
->middleware('auth')
->controller(ProfileController::class)
->group(function () {
Route::get('info', 'info')->name('info');
Route::post('edit', 'edit')->name('edit');
Route::post('change_password', 'changePassword')->name('changePassword');
Route::get('/', function () {
return view('welcome');
});

0
backend/storage/app/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/app/private/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/app/public/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/cache/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/cache/data/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/sessions/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/testing/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/framework/views/.gitignore vendored Executable file → Normal file
View File

0
backend/storage/logs/.gitignore vendored Executable file → Normal file
View File

View File

@@ -0,0 +1,60 @@
services:
postgres:
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
container_name: pgsql
restart: unless-stopped
ports:
- "8091:5432"
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- payment-db:/var/lib/postgresql/data
networks:
- payment
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 30s
timeout: 10s
retries: 3
backend:
build:
context: ${BACKEND_PATH}
dockerfile: Dockerfile.production
container_name: laravel
tty: true
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3
ports:
- "8003:80"
- "443:443"
- "443:443/udp"
volumes:
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
depends_on:
- postgres
networks:
- payment
logging:
driver: "syslog"
options:
syslog-address: "tcp://host.docker.internal:514"
tag: "laravel-backend"
syslog-facility: "daemon"
max-size: "10m"
mem_limit: 512M
cpus: 1
volumes:
payment-db:
driver: local
networks:
payment:
driver: bridge

View File

@@ -1,39 +1,14 @@
services:
nginx:
image: nginx:stable-alpine3.23-perl
container_name: nginx
restart: unless-stopped
ports:
- "8000:80"
volumes:
- ./nginx/payment.conf:/etc/nginx/conf.d/default.conf
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
networks:
- payment
redis:
image: redis:8.6.0-alpine3.23
container_name: redis
restart: unless-stopped
tty: true
networks:
- payment
postgres:
image: postgres:18.2-alpine3.23
container_name: payment-db
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
container_name: pgsql
restart: unless-stopped
ports:
- "8092:5432"
- "8091:5432"
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 30s
timeout: 10s
retries: 3
volumes:
- payment-db:/var/lib/postgresql/data
networks:
@@ -47,22 +22,17 @@ services:
tty: true
restart: unless-stopped
ports:
- "9000:9000"
- "8003:80"
- "443:443"
- "443:443/udp"
volumes:
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
# - caddy_data:/data
# - caddy_config:/config
depends_on:
- postgres
networks:
- payment
# logging:
# driver: "syslog"
# options:
# syslog-address: "tcp://host.docker.internal:514"
# tag: "laravel-backend"
# syslog-facility: "daemon"
# max-size: "10m"
# mem_limit: 512M
# cpus: 1
volumes:
payment-db:

View File

@@ -1,21 +0,0 @@
server {
listen 80;
listen [::]:80;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/index\.php(/|$) {
include fastcgi_params;
fastcgi_pass laravel:9000;
fastcgi_index index.php;
fastcgi_hide_header X-Powered-By;
fastcgi_param SCRIPT_FILENAME /var/www/payment/public/index.php;
}
location ~ /\.(?!well-known).* {
deny all;
}
}