Bu talimatlar, projeyi yerel makinenizde geliştirme ve test amaçlarıyla çalıştırmanız için bir kopyasını alıp kurmanıza yardımcı olacaktır. Daha fazla detay için lütfen ilerleyin.
Laravel projenizi yerel makinenizde çalıştırabilmek için aşağıdaki araçlara ihtiyacınız olacak:
PHP >= 8.0
Composer
Veritabanı (MySQL, PostgreSQL, SQLite, vb.)
Aşağıdaki adımlar, yerel makinenizde nasıl çalıştırılacağını açıklar:
- Projeyi klonlayın:
git clone https://github.com/smtkuo/PHP_Laravel_Subscription_Service.git
- Bağımlılıkları yükleyin:
cd PHP_Laravel_Subscription_Service
composer install
.env
dosyasını oluşturun ve düzenleyin:
cp .env.example .env
Bu dosyayı açın ve veritabanı ayarlarınızı yapın.
- Uygulama anahtarını oluşturun:
php artisan key:generate
- Veritabanını ayarlayın ve göç edin:
php artisan migrate
- Sunucuyu başlatın:
php artisan serve
Projeyi tarayıcınızda http://localhost:8000
adresinde görüntüleyebilirsiniz.
php artisan test
This repository contains a Postman collection for the API endpoints of the project. The Postman collection file is 2023_07_23_121717_laravel_collection.json.json
.
The following variables are used in this collection:
base_url
: http://localhost
The collection contains the following requests:
- Method: POST
- URL: {{base_url}}/api/register
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
name
:None
email
:None
password
:None
- Method: POST
- URL: {{base_url}}/api/login
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
email
:None
password
:None
- Method: POST
- URL: {{base_url}}/api/logout
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
No body parameters
- Method: POST
- URL: {{base_url}}/api/user/:id/subscription
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
subscription_type_id
:None
renewed_at
:None
expired_at
:None
- Method: PUT
- URL: {{base_url}}/api/user/:userId/subscription/:subscriptionId
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
subscription_type_id
:None
renewed_at
:None
expired_at
:None
- Method: DELETE
- URL: {{base_url}}/api/user/:id/subscription
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
No body parameters
- Method: POST
- URL: {{base_url}}/api/user/:id/transaction
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
subscription_id
:None
price
:None
- Method: GET
- URL: {{base_url}}/api/user/:id
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
No body parameters
- Method: GET
- URL: {{base_url}}/api/subscription-types
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
No body parameters
- Method: POST
- URL: {{base_url}}/api/subscription-types
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
name
:None
price
:None
duration
:None
details
:None
- Method: GET
- URL: {{base_url}}/api/subscription-types/{subscription_type}
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
No body parameters
- Method: PUT
- URL: {{base_url}}/api/subscription-types/{subscription_type}
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
name
:None
price
:None
duration
:None
details
:None
- Method: PATCH
- URL: {{base_url}}/api/subscription-types/{subscription_type}
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
name
:None
price
:None
duration
:None
details
:None
- Method: DELETE
- URL: {{base_url}}/api/subscription-types/{subscription_type}
Headers:
Accept
:application/json
Content-Type
:application/json
Body Parameters (if any):
No body parameters
The application provides several artisan commands for managing subscriptions:
php artisan subscription:create {userId} {subscriptionTypeId}
: This command creates a new subscription for a user.php artisan subscription:delete {subscriptionId}
: This command deletes a subscription.php artisan subscription:renew {subscriptionId}
: This command renews a subscription.php artisan subscription:update {subscriptionId} {renewedAt} {expiredAt} {subscriptionTypeId}
: This command updates a subscription.
Remember to replace the placeholders ({userId}
, {subscriptionTypeId}
, {subscriptionId}
, {renewedAt}
, {expiredAt}
) with actual values when running these commands.
The application uses background jobs for tasks that can be processed in the background. One such job is the RenewSubscriptionsJob
.
The RenewSubscriptionsJob
is responsible for renewing subscriptions that are due for renewal. It does this by using the SubscriptionService
to get all subscriptions due for renewal and renewing them. The renewal is done by calling the update
method of the SubscriptionService
, passing the user_id
, id
(subscription ID), current time (Carbon::now()
), and the time one month from now (Carbon::now()->addMonth()
) as parameters.