Upload Proyek Tugas Akhir Berbasis Mobile
This commit is contained in:
commit
481859052a
|
|
@ -0,0 +1,18 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[compose.yaml]
|
||||
indent_size = 4
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## Laravel Sponsors
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||
- **[Redberry](https://redberry.international/laravel-development)**
|
||||
- **[Active Logic](https://activelogic.com)**
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CancelOrder implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel('tenant.' . $this->order->tenant_id),
|
||||
];
|
||||
}
|
||||
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'order.canceled';
|
||||
}
|
||||
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->order->uuid,
|
||||
'outlet_id' => $this->order->outlet_id,
|
||||
'updated_at' => $this->order->updated_at->toDateTimeString()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CancellationRequest implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $order;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel('tenant.' . $this->order->tenant_id),
|
||||
];
|
||||
}
|
||||
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'order.cancellation_request';
|
||||
}
|
||||
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->order->uuid,
|
||||
'outlet_id' => $this->order->outlet_id,
|
||||
'updated_at' => $this->order->updated_at->toDateTimeString()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DataBatchUpdated implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $tenantId;
|
||||
public $changedTables;
|
||||
|
||||
/**
|
||||
* @param string $tenantId
|
||||
* @param array $changedTables
|
||||
*/
|
||||
public function __construct($tenantId, array $changedTables)
|
||||
{
|
||||
$this->tenantId = $tenantId;
|
||||
$this->changedTables = $changedTables;
|
||||
}
|
||||
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new Channel('tenant.' . $this->tenantId),
|
||||
];
|
||||
}
|
||||
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'data.batch.updated';
|
||||
}
|
||||
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'tenant_id' => $this->tenantId,
|
||||
'changed_tables' => $this->changedTables,
|
||||
'updated_at' => now()->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
// Pastikan memanggil interface yang benar di sini
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
// Tambahkan "implements ShouldBroadcastNow" agar sinyal dikirim instan tanpa antrean
|
||||
class OrderPlaced implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* Konstruktor untuk menerima objek Order
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menentukan Private Channel berdasarkan Tenant ID
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PrivateChannel('tenant.' . $this->order->tenant_id),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Nama Event yang akan didengarkan oleh Laravel Echo di Flutter
|
||||
*/
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'order.created';
|
||||
}
|
||||
|
||||
/**
|
||||
* Payload data yang dikirimkan ke WebSocket
|
||||
* Pastikan field ini sesuai dengan kolom di tabel Order Anda
|
||||
*/
|
||||
public function broadcastWith()
|
||||
{
|
||||
|
||||
return [
|
||||
'order_id' => $this->order->uuid,
|
||||
'outlet_id' => $this->order->outlet_id
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Services\AuthService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Traits\ApiResponse;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $authService;
|
||||
|
||||
public function __construct(AuthService $authService)
|
||||
{
|
||||
$this->authService = $authService;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'identifier' => 'required|string',
|
||||
'password' => 'required|string',
|
||||
'business_code' => 'nullable|string',
|
||||
]);
|
||||
|
||||
try {
|
||||
$result = $this->authService->login($request->all(), $request->ip());
|
||||
|
||||
if (isset($result['error']) && $result['error'] === 'lockout') {
|
||||
return $this->errorResponse(
|
||||
$result['error'],
|
||||
429,
|
||||
[
|
||||
'seconds_remaining' => $result['seconds'],
|
||||
'locked_until' => $result['until']
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($result['error'])) {
|
||||
return $this->errorResponse($result['error'], 401);
|
||||
}
|
||||
|
||||
return $this->successResponse([
|
||||
'access_token' => $result['token'],
|
||||
'user' => new UserResource($result['user']),
|
||||
], 'login success', 200);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('internal server error', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function register(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'business_name' => 'required|string|max:255',
|
||||
'business_code' => 'required|string|unique:tenants,business_code',
|
||||
'name' => 'required|string|max:255',
|
||||
'phone_number' => 'required|string|unique:users,phone_number',
|
||||
'email' => 'nullable|email|unique:users,email',
|
||||
'password' => 'required|min:8|confirmed',
|
||||
'password_confirmation' => 'required|min:8'
|
||||
], [
|
||||
'phone_number.unique' => 'phone number already exists',
|
||||
'email.unique' => 'email already exists',
|
||||
]);
|
||||
|
||||
try {
|
||||
$result = $this->authService->register($data);
|
||||
|
||||
return $this->successResponse([
|
||||
'business_code' => $result['business_code'],
|
||||
'owner_name' => $result['user']->name,
|
||||
], 'registration success', 201);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('internal server error', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Events\OrderPlaced;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\CheckoutService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CheckoutController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $checkoutService;
|
||||
|
||||
public function __construct(CheckoutService $checkoutService)
|
||||
{
|
||||
$this->checkoutService = $checkoutService;
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = json_decode($request->input('data'), true);
|
||||
|
||||
if (!$data) {
|
||||
throw new \Exception("Invalid order data format");
|
||||
}
|
||||
|
||||
$order = $this->checkoutService->execute(
|
||||
$data,
|
||||
$request->file('payment_proof_file')
|
||||
);
|
||||
|
||||
broadcast(new OrderPlaced($order))->toOthers();
|
||||
|
||||
return $this->successResponse([
|
||||
'order_id' => $order->uuid,
|
||||
'order_number' => $order->order_number
|
||||
], 'Process checkout successfully');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('Failed to process checkout', 400, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ConfigurationService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ConfigurationController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $configurationService;
|
||||
|
||||
public function __construct(ConfigurationService $configurationService)
|
||||
{
|
||||
$this->configurationService = $configurationService;
|
||||
}
|
||||
|
||||
public function getConfigurationService()
|
||||
{
|
||||
try {
|
||||
$data = $this->configurationService->getConfigurationService();
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to fetch configuration service', 400, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\CustomerResource;
|
||||
use App\Services\CustomerService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $customerService;
|
||||
|
||||
public function __construct(CustomerService $customerService)
|
||||
{
|
||||
$this->customerService = $customerService;
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'identifier' => 'required|string',
|
||||
'password' => 'required|string',
|
||||
'business_code' => 'nullable|string',
|
||||
]);
|
||||
|
||||
try {
|
||||
$result = $this->customerService->login($request->all(), $request->ip());
|
||||
|
||||
if (isset($result['error']) && $result['error'] === 'lockout') {
|
||||
return $this->errorResponse(
|
||||
$result['error'],
|
||||
429,
|
||||
[
|
||||
'seconds_remaining' => $result['seconds'],
|
||||
'locked_until' => $result['until']
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($result['error'])) {
|
||||
return $this->errorResponse($result['error'], 401);
|
||||
}
|
||||
|
||||
return $this->successResponse([
|
||||
'access_token' => $result['token'],
|
||||
'customer' => new CustomerResource($result['customer'])
|
||||
], 'login success', 200);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('internal server error', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function register(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->customerService->register($request->all());
|
||||
return $this->successResponse(null, 'registration success', 201);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('internal server error', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePassword(Request $request, $customerId)
|
||||
{
|
||||
try {
|
||||
$result = $this->customerService->updatePassword($request->all(), $customerId);
|
||||
|
||||
if(isset($result['error'])) {
|
||||
return $this->errorResponse('internal server error', 500, $result['error']);
|
||||
}
|
||||
return $this->successResponse(null, 'update password success', 201);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('internal server error', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateCustomer(Request $request, $customerId)
|
||||
{
|
||||
try {
|
||||
$data = $request->all();
|
||||
$customerInfo = $this->customerService->updateCustomer($data, $customerId);
|
||||
return $this->successResponse($customerInfo, 'Update customer successfully');
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to update customer', errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getCustomerAddress($customerId)
|
||||
{
|
||||
try {
|
||||
$customerAddress = $this->customerService->getCustomerAddress($customerId);
|
||||
return $this->successResponse($customerAddress);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('Failed to retrieve customer address', errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function saveCustomerAddress(Request $request, $customerId)
|
||||
{
|
||||
try {
|
||||
$data = $request->all();
|
||||
$this->customerService->saveCustomerAddress($data, $customerId);
|
||||
return $this->successResponse(null, 'Save customer address successfully');
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to save customer address', errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCustomerAddress($customerId, $id)
|
||||
{
|
||||
try {
|
||||
$this->customerService->deleteCustomerAddress($customerId, $id);
|
||||
return $this->successResponse(null, 'Delete customer address successfully');
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to delete customer address', errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\HomeService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $homeService;
|
||||
|
||||
public function __construct(HomeService $homeService)
|
||||
{
|
||||
$this->homeService = $homeService;
|
||||
}
|
||||
|
||||
public function home($outletId)
|
||||
{
|
||||
try {
|
||||
$data = $this->homeService->home($outletId);
|
||||
|
||||
return $this->successResponse($data);
|
||||
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getOutlets()
|
||||
{
|
||||
try {
|
||||
$data = $this->homeService->getOutlets();
|
||||
|
||||
return $this->successResponse($data);
|
||||
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getMainOutlet()
|
||||
{
|
||||
try {
|
||||
$data = $this->homeService->getMainOutlet();
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Events\CancellationRequest;
|
||||
use App\Events\CancelOrder;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\OrderService;
|
||||
use App\Traits\ApiResponse;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $orderService;
|
||||
|
||||
public function __construct(OrderService $orderService)
|
||||
{
|
||||
$this->orderService = $orderService;
|
||||
}
|
||||
|
||||
public function getOrderSync($orderId)
|
||||
{
|
||||
try {
|
||||
$data = $this->orderService->getOrderSync($orderId);
|
||||
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getOrders($customerId)
|
||||
{
|
||||
try {
|
||||
$data = $this->orderService->getOrders($customerId);
|
||||
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getOrderById($customerId, $orderId)
|
||||
{
|
||||
try {
|
||||
$data = $this->orderService->getOrderById($customerId, $orderId);
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails: $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function cancelOrder($customerId, $orderId)
|
||||
{
|
||||
try {
|
||||
$order = $this->orderService->cancelOrder($customerId, $orderId);
|
||||
|
||||
broadcast(new CancelOrder($order))->toOthers();
|
||||
|
||||
return $this->successResponse(null, 'Cancel order successfully');
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to cancel order', 400, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function cancellationRequest($customerId, $orderId)
|
||||
{
|
||||
try {
|
||||
$order = $this->orderService->cancellationRequest($customerId, $orderId);
|
||||
|
||||
broadcast(new CancellationRequest($order))->toOthers();
|
||||
|
||||
return $this->successResponse(null, 'Cancellation order request successfully');
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to cancellation order request', 400, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ProductService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $productService;
|
||||
|
||||
public function __construct(ProductService $productService)
|
||||
{
|
||||
$this->productService = $productService;
|
||||
}
|
||||
|
||||
public function getProductById($id)
|
||||
{
|
||||
try {
|
||||
$data = $this->productService->getProductById($id);
|
||||
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails:$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getProductByName(Request $request, $currentOutletId)
|
||||
{
|
||||
$name = $request->query('name');
|
||||
|
||||
try {
|
||||
$data = $this->productService->getProductByName($currentOutletId, $name);
|
||||
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails:$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getProductByCategory($currentOutletId, $categoryId)
|
||||
{
|
||||
try {
|
||||
$data = $this->productService->getProductByCategory($currentOutletId, $categoryId);
|
||||
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails:$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getProductBestSellerByOutlet($currentOutletId)
|
||||
{
|
||||
try {
|
||||
$data = $this->productService->getProductBestSellerByOutlet($currentOutletId);
|
||||
|
||||
return $this->successResponse($data);
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(errorDetails:$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ReviewService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReviewController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $reviewService;
|
||||
|
||||
public function __construct(ReviewService $reviewService)
|
||||
{
|
||||
$this->reviewService = $reviewService;
|
||||
}
|
||||
|
||||
public function getProductReviewItem($orderId)
|
||||
{
|
||||
try {
|
||||
$data = $this->reviewService->getProductReviewItem($orderId);
|
||||
return $this->successResponse($data, 'Fetching product review item successfully');
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to fetch product review item', 400, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function reviewProduct(Request $request, $orderId)
|
||||
{
|
||||
try {
|
||||
$this->reviewService->reviewProduct($request->all(), $orderId);
|
||||
return $this->successResponse(null, 'Review product successfully');
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse('Failed to review product', 400, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\SyncService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SyncController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $syncService;
|
||||
|
||||
public function __construct(SyncService $syncService)
|
||||
{
|
||||
$this->syncService = $syncService;
|
||||
}
|
||||
|
||||
public function getDeltaSync(Request $request)
|
||||
{
|
||||
$lastSync = $request->query('last_sync');
|
||||
try {
|
||||
$currentTime = Carbon::now();
|
||||
|
||||
$data = $this->syncService->getDeltaSync($lastSync);
|
||||
|
||||
$this->syncService->updateServerTime($currentTime);
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'server_time' => $currentTime->toDateTimeString(),
|
||||
'data' => $data
|
||||
], 200);
|
||||
} catch(\Exception $e) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function batchUpSync(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'batch_id' => 'required|string',
|
||||
'items' => 'required|array',
|
||||
]);
|
||||
|
||||
$payload = $request->all();
|
||||
|
||||
$payload['items'] = array_map(function($item) {
|
||||
return is_string($item) ? json_decode($item, true) : $item;
|
||||
}, $payload['items']);
|
||||
|
||||
try {
|
||||
$report = $this->syncService->processBatchSync($payload);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'batch_id' => $request->batch_id,
|
||||
'report' => $report,
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\UploadService;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
protected $uploadService;
|
||||
|
||||
public function __construct(UploadService $uploadService)
|
||||
{
|
||||
$this->uploadService = $uploadService;
|
||||
}
|
||||
|
||||
public function uploadImage(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'image' => 'required|image|max:5120',
|
||||
'type' => 'required|string'
|
||||
]);
|
||||
|
||||
try {
|
||||
$serverPath = $this->uploadService->uploadImage(
|
||||
$request->file('image'),
|
||||
$request->type
|
||||
);
|
||||
|
||||
return $this->successResponse(['server_path' => $serverPath ],'upload image success', 200);
|
||||
} catch (\Exception $e) {
|
||||
return $this->errorResponse('upload image failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class IdentifyTenant
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$businessCode = $request->header('X-Business-Code');
|
||||
|
||||
if (!$businessCode) {
|
||||
return response()->json(['error' => 'Missing Business Code Header'], 403);
|
||||
}
|
||||
|
||||
$tenant = Tenant::where('business_code', $businessCode)->first();
|
||||
|
||||
if (!$tenant) {
|
||||
return response()->json(['error' => 'Business not found'], 404);
|
||||
}
|
||||
|
||||
Config::set('app.current_tenant_id', $tenant->uuid);
|
||||
|
||||
Config::set('app.current_tenant_code', $businessCode);
|
||||
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CustomerResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone_number' => $this->phone_number
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Home;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AllCategoriesResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'server_image_url' => $this->server_image_url,
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Home;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CampaignByOutletResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'campaign_type' => $this->action_type,
|
||||
'action_ref_id' => $this->action_reference_id,
|
||||
'server_banner_url' => $this->server_banner_url
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Home;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CurrentOutletResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'name' => $this->name,
|
||||
'location' => $this->full_address,
|
||||
'latitude' => (float) $this->latitude,
|
||||
'longitude' => (float) $this->longitude,
|
||||
'is_active' => $this->is_active
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Home;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OtherOutletResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'server_banner_url' => $this->server_banner_url,
|
||||
'name' => $this->name,
|
||||
'phone_number' => $this->phone_number,
|
||||
'location' => $this->full_address,
|
||||
'latitude' => (float) $this->latitude,
|
||||
'longitude' => (float) $this->longitude,
|
||||
'is_active' => $this->is_active
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Home;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ProductByOutletResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'server_image_url' => Arr::last($this->server_image_url),
|
||||
'name' => $this->name,
|
||||
'total_sold' => (int) $this->total_sold,
|
||||
'average_rating' => round($this->average_rating, 2),
|
||||
'selling_price' => optional($this->variants->first()?->inventory)->selling_price,
|
||||
'likes' => $this->likes_count ?? 0
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Home;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductCategoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'server_image_url' => $this->server_image_url,
|
||||
''
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Order;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderInfoResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'order_number' => $this->order_number,
|
||||
'created_at' => $this->created_at->toDateTimeString(),
|
||||
'order_status' => $this->order_status,
|
||||
'is_cancellation' => $this->is_cancellation,
|
||||
'cancellation_accepted' => $this->cancellation_accepted,
|
||||
'approval_process' => $this->approval_process,
|
||||
'delivery_type' => $this->delivery_type,
|
||||
'delivery_preference' => $this->delivery_preference,
|
||||
'outlet_name_snapshot' => $this->outlet_name_snapshot,
|
||||
'outlet_address_snapshot' => $this->outlet_address_snapshot,
|
||||
'customer_address_snapshot' => $this->customer_address_snapshot,
|
||||
'order_items' => OrderItemInfoResource::collection($this->whenLoaded('items')),
|
||||
'payment_method' => $this->payment_method,
|
||||
'payment_proof_url' => $this->payment_proof_url,
|
||||
'total_order' => (float) $this->total_order,
|
||||
'delivery_fee_type' => $this->delivery_fee_type,
|
||||
'delivery_fee' => (float) $this->delivery_fee,
|
||||
'total_delivery_fee' => (float) $this->total_delivery_fee,
|
||||
'total_amount' => (float) $this->total_amount
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Order;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderItemInfoResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->variant->product_id,
|
||||
'product_image_url_snapshot' => $this->product_image_url_snapshot,
|
||||
'product_name_snapshot' => $this->product_name_snapshot,
|
||||
'product_variant_name_snapshot' => $this->product_variant_name_snapshot,
|
||||
'selling_price_snapshot' => (float) $this->selling_price_snapshot,
|
||||
'quantity' => (int) $this->quantity
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Order;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderReportResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'product_images' => $this->whenLoaded('items')
|
||||
->pluck('product_image_url_snapshot')
|
||||
->values(),
|
||||
'total_items' => $this->total_items,
|
||||
'order_number' => $this->order_number,
|
||||
'total_amount' => $this->total_amount,
|
||||
'order_status' => $this->order_status,
|
||||
'delivery_type' => $this->delivery_type,
|
||||
'has_been_assessed' => $this->has_been_assessed,
|
||||
'created_at' => $this->created_at->toDateTimeString()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Order;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrderSyncResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'order' => [
|
||||
'uuid' => $this->uuid,
|
||||
'order_number' => $this->order_number,
|
||||
'outlet_id' => $this->outlet_id,
|
||||
'outlet_name_snapshot' => $this->outlet_name_snapshot,
|
||||
'outlet_phone_number_snapshot' => $this->outlet_phone_number_snapshot,
|
||||
'outlet_address_snapshot' => $this->outlet_address_snapshot,
|
||||
'customer_id' => $this->customer_id,
|
||||
'customer_name_snapshot' => $this->customer_name_snapshot,
|
||||
'customer_email_snapshot' => $this->customer_email_snapshot,
|
||||
'customer_phone_number_snapshot' => $this->customer_phone_number_snapshot,
|
||||
'customer_address_snapshot' => $this->customer_address_snapshot,
|
||||
'source' => $this->source,
|
||||
'already_read' => $this->already_read,
|
||||
'order_status' => $this->order_status,
|
||||
'delivery_type' => $this->delivery_type,
|
||||
'delivery_preference' => $this->delivery_preference,
|
||||
'delivery_fee_type' => $this->delivery_fee_type,
|
||||
'delivery_fee' => (float) $this->delivery_fee,
|
||||
'total_delivery_fee' => (float) $this->total_delivery_fee,
|
||||
'total_order' => (float) $this->total_order,
|
||||
'total_amount' => (float) $this->total_amount,
|
||||
'notes' => $this->notes,
|
||||
'payment_proof_url' => $this->payment_proof_url,
|
||||
'payment_method' => $this->payment_method,
|
||||
'created_at' => $this->created_at->toDateTimeString(),
|
||||
'updated_at' => $this->updated_at->toDateTimeString(),
|
||||
],
|
||||
'items' => $this->whenLoaded('items'),
|
||||
'customer' => $this->whenLoaded('customer'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Order;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductImageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return $this->product_image_url_snapshot;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OutletResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone_number' => $this->phone_number,
|
||||
'full_address' => $this->full_address,
|
||||
'latitude' => (float) $this->latitude,
|
||||
'longitude' => (float) $this->longitude,
|
||||
'server_photo_url' => $this->server_photo_url,
|
||||
'server_banner_url' => $this->server_banner_url,
|
||||
'is_main_outlet' => (bool) $this->is_main_outlet,
|
||||
'is_active' => (bool) $this->is_active,
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Product;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductInfoResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'server_image_url' => $this->server_image_url,
|
||||
'name' => $this->name,
|
||||
'has_variant' => $this->has_variant,
|
||||
'description' => $this->description,
|
||||
'unit' => $this->unit->name,
|
||||
'variants' => ProductVariantResource::collection($this->whenLoaded('variants')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Product;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductReviewResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'customer_name' => $this->customer->name,
|
||||
'rating_count' => $this->rating,
|
||||
'comment' => $this->comment
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources\Product;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ProductVariantResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->uuid,
|
||||
'server_image_url' => $this->server_image_url,
|
||||
'name' => $this->name,
|
||||
'is_product_variant' => $this->is_product_variant,
|
||||
'selling_price' => $this->inventory->selling_price,
|
||||
'stock_type' => $this->inventory->stock_type,
|
||||
'stock' => $this->inventory->stock,
|
||||
'total_sold' => $this->total_sold,
|
||||
'reviews' => ProductReviewResource::collection($this->whenLoaded('reviews'))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class StaffResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'outlet_id' => $this->outlet?->uuid,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone_number' => $this->phone_number,
|
||||
'role' => $this->role,
|
||||
'place_of_birth' => $this->place_of_birth,
|
||||
'date_of_birth' => $this->date_of_birth,
|
||||
'shift_name' => $this->shift_name,
|
||||
'shift_start_time' => $this->shift_start_time,
|
||||
'shift_end_time' => $this->shift_end_time,
|
||||
'is_active' => (bool) $this->is_active,
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TenantResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'business_code' => $this->business_code,
|
||||
'business_name' => $this->business_name,
|
||||
'business_email' => $this->business_email,
|
||||
'business_phone' => $this->business_phone,
|
||||
'business_type' => $this->business_type,
|
||||
'server_logo_url' => $this->server_logo_url,
|
||||
'subdomain' => $this->subdomain,
|
||||
'online_store_name' => $this->online_store_name,
|
||||
'online_open_time' => $this->online_open_time,
|
||||
'online_close_time' => $this->online_close_time,
|
||||
'is_close_service' => (bool) $this->is_close_service,
|
||||
'preparation_time_minutes' => (int) $this->preparation_time_minutes,
|
||||
'order_interval_minutes' => (int) $this->order_interval_minutes,
|
||||
'allow_cod' => (bool) $this->allow_cod,
|
||||
'max_delivery_radius_km' => (float) $this->max_delivery_radius_km,
|
||||
'delivery_fee_type' => $this->delivery_fee_type,
|
||||
'delivery_flat_fee' => (float) $this->delivery_flat_fee,
|
||||
'delivery_fee_per_km' => (float) $this->delivery_fee_per_km,
|
||||
'delivery_base_fee' => (float) $this->delivery_base_fee,
|
||||
'review_display_type' => $this->review_display_type,
|
||||
'review_display_policy' => $this->review_display_policy,
|
||||
'subscription_level' => $this->subscription_level,
|
||||
'limit_outlet' => (int) $this->limit_outlet,
|
||||
'subscription_expires_at' => $this->subscription_expires_at?->toIso8601String(),
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Http\Resources\TenantResource;
|
||||
use App\Http\Resources\OutletResource;
|
||||
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'tenant' => new TenantResource($this->whenLoaded('tenant')? : $this->tenant),
|
||||
'outlet_id' => $this->outlet->uuid,
|
||||
'outlets' => $this->role === 'owner'
|
||||
? OutletResource::collection($this->tenant->outlets)
|
||||
: new OutletResource($this->outlet),
|
||||
'staff_list' => $this->role === 'owner'
|
||||
? StaffResource::collection($this->tenant->users->where('uuid', '!=', $this->uuid))
|
||||
: [],
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'phone_number' => $this->phone_number,
|
||||
'role' => $this->role,
|
||||
'place_of_birth' => $this->place_of_birth,
|
||||
'date_of_birth' => $this->date_of_birth,
|
||||
'shift_name' => $this->shift_name,
|
||||
'shift_start_time' => $this->shift_start_time,
|
||||
'shift_end_time' => $this->shift_end_time,
|
||||
'is_active' => (bool) $this->is_active,
|
||||
'last_sync' => $this->last_sync?->toIso8601String(),
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Campaign extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
public $imageFields = ['server_banner_url'];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'title',
|
||||
'server_banner_url',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'action_type',
|
||||
'action_reference_id',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function outlet_campaigns() {
|
||||
return $this->hasMany(OutletCampaign::class, 'campaign_id', 'uuid');
|
||||
}
|
||||
|
||||
public function getServerBannerUrlAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
return asset('storage/' . $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
public $imageFields = ['server_image_url'];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'name',
|
||||
'server_image_url'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime'
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->hasMany(Product::class, 'category_id', 'uuid');
|
||||
}
|
||||
|
||||
public function getServerImageUrlAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
return asset('storage/' . $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class Customer extends Authenticatable
|
||||
{
|
||||
use SoftDeletes, Multitenantable, HasApiTokens;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'outlet_id',
|
||||
'name',
|
||||
'email',
|
||||
'phone_number',
|
||||
'password',
|
||||
'source'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function addresses(): HasMany
|
||||
{
|
||||
return $this->hasMany(CustomerAddress::class, 'customer_id', 'uuid');
|
||||
}
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->hasMany(Order::class, 'customer_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class CustomerAddress extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'customer_id',
|
||||
'label',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'notes'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'order_number',
|
||||
'outlet_id',
|
||||
'outlet_name_snapshot',
|
||||
'outlet_phone_number_snapshot',
|
||||
'outlet_address_snapshot',
|
||||
'customer_id',
|
||||
'customer_name_snapshot',
|
||||
'customer_email_snapshot',
|
||||
'customer_phone_number_snapshot',
|
||||
'customer_address_snapshot',
|
||||
'user_id',
|
||||
'admin_name_snapshot',
|
||||
'source',
|
||||
'already_read',
|
||||
'order_status',
|
||||
'is_cancellation',
|
||||
'cancellation_accepted',
|
||||
'approval_process',
|
||||
'canceled_by',
|
||||
'delivery_type',
|
||||
'delivery_preference',
|
||||
'delivery_fee_type',
|
||||
'delivery_fee',
|
||||
'total_delivery_fee',
|
||||
'total_order',
|
||||
'discount',
|
||||
'tax',
|
||||
'total_amount',
|
||||
'amount_paid',
|
||||
'change_amount',
|
||||
'notes',
|
||||
'payment_proof_url',
|
||||
'payment_method',
|
||||
'has_been_assessed'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'outlet_address_snapshot' => 'array',
|
||||
'customer_address_snapshot' => 'array',
|
||||
'already_read' => 'boolean',
|
||||
'is_cancellation' => 'boolean',
|
||||
'cancellation_accepted' => 'boolean',
|
||||
'has_been_assessed' => 'boolean'
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(OrderItem::class, 'order_id', 'uuid');
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id', 'uuid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke tabel Transactions sebagai polimorfik
|
||||
*/
|
||||
public function transaction(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Transaction::class, 'reference', 'reference_type', 'reference_id', 'uuid');
|
||||
}
|
||||
|
||||
public function getPaymentProofUrlAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
return asset('storage/' . $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class OrderItem extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'order_id',
|
||||
'product_variant_id',
|
||||
'quantity',
|
||||
'product_image_url_snapshot',
|
||||
'product_name_snapshot',
|
||||
'product_variant_name_snapshot',
|
||||
'selling_price_snapshot',
|
||||
'subtotal'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function order(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id', 'uuid');
|
||||
}
|
||||
public function variant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ProductVariant::class, 'product_variant_id', 'uuid');
|
||||
}
|
||||
|
||||
public function getProductImageUrlSnapshotAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
return asset('storage/' . $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Outlet extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
public $imageFields = ['server_photo_url', 'server_banner_url'];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'name',
|
||||
'email',
|
||||
'phone_number',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'server_photo_url',
|
||||
'server_banner_url',
|
||||
'is_main_outlet',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_main_outlet' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
// Outlet ini milik Tenant mana
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class, 'tenant_id', 'uuid');
|
||||
}
|
||||
|
||||
// Daftar User/Staf yang terdaftar di Outlet ini
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'outlet_id', 'uuid');
|
||||
}
|
||||
|
||||
public function getServerBannerUrlAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
return asset('storage/' . $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class OutletCampaign extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'campaign_id',
|
||||
'outlet_id'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function campaign() {
|
||||
return $this->belongsTo(Campaign::class, 'campaign_id', 'uuid');
|
||||
}
|
||||
|
||||
public function outlet() {
|
||||
return $this->belongsTo(Outlet::class, 'outlet_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class OutletInventory extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'outlet_id',
|
||||
'item_type',
|
||||
'item_id',
|
||||
'stock_type',
|
||||
'stock',
|
||||
'selling_price',
|
||||
'cost_price',
|
||||
'purchase_price',
|
||||
'is_delete_by_owner'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_delete_by_owner' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function item()
|
||||
{
|
||||
return $this->morphTo('item', 'item_type', 'item_id');
|
||||
}
|
||||
|
||||
public function stockCards()
|
||||
{
|
||||
return $this->hasMany(StockCard::class, 'outlet_inventory_id');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
public $imageFields = ['server_image_url'];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'category_id',
|
||||
'unit_id',
|
||||
'name',
|
||||
'server_image_url',
|
||||
'has_variant',
|
||||
'description'
|
||||
];
|
||||
protected $casts = [
|
||||
'has_variant' => 'boolean',
|
||||
'server_image_url' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class, 'category_id');
|
||||
}
|
||||
|
||||
public function unit()
|
||||
{
|
||||
return $this->belongsTo(Unit::class, 'unit_id');
|
||||
}
|
||||
|
||||
public function variants()
|
||||
{
|
||||
return $this->hasMany(ProductVariant::class, 'product_id');
|
||||
}
|
||||
|
||||
public function likes()
|
||||
{
|
||||
return $this->hasMany(ProductLike::class, 'product_id');
|
||||
}
|
||||
|
||||
public function getServerImageUrlAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
$paths = is_array($value) ? $value : json_decode($value, true);
|
||||
|
||||
return collect($paths)->map(function ($path) {
|
||||
return asset('storage/' . $path);
|
||||
})->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductLike extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'customer_id',
|
||||
'product_id',
|
||||
'is_like'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_like' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
|
||||
public function customer() {
|
||||
return $this->belongsTo(Customer::class, 'customer_id', 'uuid');
|
||||
}
|
||||
|
||||
public function product() {
|
||||
return $this->belongsTo(Product::class, 'product_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductReview extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'customer_id',
|
||||
'product_variant_id',
|
||||
'rating',
|
||||
'comment'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function customer() {
|
||||
return $this->belongsTo(Customer::class, 'customer_id', 'uuid');
|
||||
}
|
||||
|
||||
public function variant() {
|
||||
return $this->belongsTo(ProductVariant::class, 'product_variant_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProductVariant extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
public $imageFields = ['server_image_url'];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'product_id',
|
||||
'name',
|
||||
'server_image_url',
|
||||
'is_visible_online',
|
||||
'total_rating',
|
||||
'average_rating',
|
||||
'total_sold',
|
||||
'is_product_variant'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_visible_online' => 'boolean',
|
||||
'is_product_variant' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'product_id');
|
||||
}
|
||||
|
||||
public function inventory()
|
||||
{
|
||||
return $this->morphOne(OutletInventory::class, 'item');
|
||||
}
|
||||
|
||||
public function reviews()
|
||||
{
|
||||
return $this->hasMany(ProductReview::class, 'product_variant_id', 'uuid');
|
||||
}
|
||||
|
||||
public function getServerImageUrlAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
return asset('storage/' . $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
|
||||
class Purchase extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'purchase_number',
|
||||
'outlet_id',
|
||||
'outlet_name_snapshot',
|
||||
'supplier_id',
|
||||
'supplier_name_snapshot',
|
||||
'supplier_email_snapshot',
|
||||
'supplier_phone_number_snapshot',
|
||||
'user_id', 'admin_name_snapshot',
|
||||
'purchase_status',
|
||||
'total_purchase',
|
||||
'discount',
|
||||
'tax',
|
||||
'payment_status',
|
||||
'total_amount',
|
||||
'amount_paid',
|
||||
'change_amount',
|
||||
'under_payment_amount',
|
||||
'debt_amount',
|
||||
'payment_proof_url',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function items() {
|
||||
return $this->hasMany(PurchaseItem::class, 'purchase_id', 'uuid');
|
||||
}
|
||||
|
||||
public function supplier() {
|
||||
return $this->belongsTo(Supplier::class, 'supplier_id', 'uuid');
|
||||
}
|
||||
|
||||
public function transaction(): MorphOne {
|
||||
return $this->morphOne(Transaction::class, 'reference', 'reference_type', 'reference_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PurchaseItem extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'purchase_id',
|
||||
'item_type',
|
||||
'item_id',
|
||||
'quantity',
|
||||
'item_image_url_snapshot',
|
||||
'item_name_snapshot',
|
||||
'item_variant_name_snapshot',
|
||||
'purchase_price_snapshot',
|
||||
'subtotal',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function purchase() {
|
||||
return $this->belongsTo(Purchase::class, 'purchase_id', 'uuid');
|
||||
}
|
||||
|
||||
// Relasi dinamis tergantung item_type (Product/RawMaterial)
|
||||
public function item() {
|
||||
return $this->morphTo(null, 'item_type', 'item_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class RawMaterial extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'unit_id',
|
||||
'name'
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ReceiptItem extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'product_variant_id',
|
||||
'raw_material_id',
|
||||
'quantity'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class StockCard extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
public $keyType = 'string';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'outlet_inventory_id',
|
||||
'user_id',
|
||||
'type',
|
||||
'reference_id',
|
||||
'receive_from_id',
|
||||
'receive_from_name',
|
||||
'document_number',
|
||||
'qty_change',
|
||||
'current_stock',
|
||||
'stock_type',
|
||||
'mode_change',
|
||||
'mode_before_change',
|
||||
'mode_after_change',
|
||||
'cost_price',
|
||||
'notes',
|
||||
'created_at'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'mode_change' => 'boolean',
|
||||
'created_at' => 'datetime'
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Supplier extends Model
|
||||
{
|
||||
use SoftDeletes, Multitenantable;
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'name',
|
||||
'email',
|
||||
'phone_number',
|
||||
'address'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function purchases() {
|
||||
return $this->hasMany(Purchase::class, 'supplier_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SyncDelete extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'table_name',
|
||||
'record_uuid',
|
||||
'created_at'
|
||||
];
|
||||
|
||||
// Matikan updated_at karena kita hanya butuh created_at untuk log
|
||||
const UPDATED_AT = null;
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Tenant extends Model
|
||||
{
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
public $imageFields = ['server_logo_url'];
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'business_code',
|
||||
'business_name',
|
||||
'business_email',
|
||||
'business_phone',
|
||||
'business_type',
|
||||
'server_logo_url',
|
||||
'subdomain',
|
||||
'online_store_name',
|
||||
'online_open_time',
|
||||
'online_close_time',
|
||||
'is_close_service',
|
||||
'preparation_time_minutes',
|
||||
'order_interval_minutes',
|
||||
'allow_cod',
|
||||
'max_delivery_radius_km',
|
||||
'delivery_fee_type',
|
||||
'delivery_flat_fee',
|
||||
'delivery_fee_per_km',
|
||||
'delivery_base_fee',
|
||||
'review_display_type',
|
||||
'review_display_policy',
|
||||
'subscripton_level',
|
||||
'limit_outlet',
|
||||
'subscription_expires_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_close_service' => 'boolean',
|
||||
'allow_cod' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'tenant_id', 'uuid');
|
||||
}
|
||||
|
||||
public function outlets(): HasMany
|
||||
{
|
||||
return $this->hasMany(Outlet::class, 'tenant_id', 'uuid');
|
||||
}
|
||||
|
||||
public function payment_methods(): HasMany
|
||||
{
|
||||
return $this->hasMany(TenantPaymentMethod::class, 'tenant_id', 'uuid');
|
||||
}
|
||||
|
||||
public function getServerLogoUrlAttribute($value)
|
||||
{
|
||||
if (!$value) return null;
|
||||
|
||||
return asset('storage/' . $value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TenantPaymentMethod extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'source_name',
|
||||
'account_number',
|
||||
'receipent_name',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
public function tenant() {
|
||||
return $this->belongsTo(Tenant::class, 'tenant_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
protected $primaryKey = 'uuid';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'outlet_id',
|
||||
'user_id',
|
||||
'reference_type',
|
||||
'reference_id',
|
||||
'reference_number',
|
||||
'stakeholder',
|
||||
'transaction_type',
|
||||
'category',
|
||||
'amount',
|
||||
'notes'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi Polimorfik ke Orders atau Purchases
|
||||
*/
|
||||
public function reference(): MorphTo
|
||||
{
|
||||
return $this->morphTo('reference', 'reference_type', 'reference_id', 'uuid');
|
||||
}
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class, 'tenant_id', 'uuid');
|
||||
}
|
||||
public function outlet(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Outlet::class, 'outlet_id', 'uuid');
|
||||
}
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Unit extends Model
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'name'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Multitenantable;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use SoftDeletes, Multitenantable, HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
public $primaryKey = 'uuid';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'tenant_id',
|
||||
'outlet_id',
|
||||
'name',
|
||||
'email',
|
||||
'phone_number',
|
||||
'password',
|
||||
'role',
|
||||
'place_of_birth',
|
||||
'date_of_birth',
|
||||
'shift_name',
|
||||
'shift_start_time',
|
||||
'shift_end_time',
|
||||
'is_active',
|
||||
'last_sync',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'last_sync' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected function serializeDate(DateTimeInterface $date)
|
||||
{
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke Tenant (Satu User memiliki satu Tenant)
|
||||
*/
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class, 'tenant_id', 'uuid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke Outlet (Satu User terikat ke satu Outlet, opsional untuk Owner)
|
||||
*/
|
||||
public function outlet(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Outlet::class, 'outlet_id', 'uuid');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\SyncDelete;
|
||||
|
||||
class SyncDeleteObserver
|
||||
{
|
||||
public function deleted($model)
|
||||
{
|
||||
SyncDelete::create([
|
||||
'table_name' => $model->getTable(),
|
||||
'record_uuid' => $model->uuid,
|
||||
'created_at' => $model->deleted_at
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Campaign;
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerAddress;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\Outlet;
|
||||
use App\Models\OutletCampaign;
|
||||
use App\Models\OutletInventory;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductVariant;
|
||||
use App\Models\RawMaterial;
|
||||
use App\Models\ReceiptItem;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use App\Observers\SyncDeleteObserver;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Relation::morphMap([
|
||||
'product_variant' => ProductVariant::class,
|
||||
'raw_material' => RawMaterial::class,
|
||||
]);
|
||||
|
||||
$models = [
|
||||
Campaign::class,
|
||||
Outlet::class,
|
||||
OutletCampaign::class,
|
||||
User::class,
|
||||
Product::class,
|
||||
ProductVariant::class,
|
||||
RawMaterial::class,
|
||||
ReceiptItem::class,
|
||||
OutletInventory::class,
|
||||
Customer::class,
|
||||
CustomerAddress::class,
|
||||
Supplier::class
|
||||
];
|
||||
|
||||
foreach ($models as $model) {
|
||||
$model::observe(SyncDeleteObserver::class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Telescope\IncomingEntry;
|
||||
use Laravel\Telescope\Telescope;
|
||||
use Laravel\Telescope\TelescopeApplicationServiceProvider;
|
||||
|
||||
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
// Telescope::night();
|
||||
|
||||
$this->hideSensitiveRequestDetails();
|
||||
|
||||
$isLocal = $this->app->environment('local');
|
||||
|
||||
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
|
||||
return $isLocal ||
|
||||
$entry->isReportableException() ||
|
||||
$entry->isFailedRequest() ||
|
||||
$entry->isFailedJob() ||
|
||||
$entry->isScheduledTask() ||
|
||||
$entry->hasMonitoredTag();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent sensitive request details from being logged by Telescope.
|
||||
*/
|
||||
protected function hideSensitiveRequestDetails(): void
|
||||
{
|
||||
if ($this->app->environment('local')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Telescope::hideRequestParameters(['_token']);
|
||||
|
||||
Telescope::hideRequestHeaders([
|
||||
'cookie',
|
||||
'x-csrf-token',
|
||||
'x-xsrf-token',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Telescope gate.
|
||||
*
|
||||
* This gate determines who can access Telescope in non-local environments.
|
||||
*/
|
||||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewTelescope', function (User $user) {
|
||||
return in_array($user->email, [
|
||||
//
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Outlet;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AuthService
|
||||
{
|
||||
public function login(array $data, string $ip)
|
||||
{
|
||||
$identifier = $data['identifier'];
|
||||
$businessCode = $data['business_code'] ?? null;
|
||||
$throttleKey = Str::lower($identifier) . '|' . $ip;
|
||||
|
||||
if (RateLimiter::tooManyAttempts($throttleKey, 6)) {
|
||||
$seconds = RateLimiter::availableIn($throttleKey);
|
||||
return [
|
||||
'error' => 'lockout',
|
||||
'seconds' => $seconds,
|
||||
'until' => now()->addSeconds($seconds)->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
$query = User::withoutGlobalScopes();
|
||||
|
||||
if ($businessCode) {
|
||||
$tenant = Tenant::where('business_code', '=', $businessCode)->first();
|
||||
|
||||
if(!$tenant) {
|
||||
return ['error' => 'invalid_business_code'];
|
||||
}
|
||||
|
||||
$query->where('tenant_id', '=', $tenant->uuid);
|
||||
}
|
||||
|
||||
$loginField = filter_var($identifier, FILTER_VALIDATE_EMAIL) ? 'email' : 'phone_number';
|
||||
|
||||
$user = $query->where($loginField, $identifier)->first();
|
||||
|
||||
$storedHash = $user->password;
|
||||
|
||||
if (str_starts_with($storedHash, '$2a$')) {
|
||||
$storedHash = str_replace('$2a$', '$2y$', $storedHash);
|
||||
}
|
||||
|
||||
if (!$user || !Hash::check($data['password'], $storedHash)) {
|
||||
RateLimiter::hit($throttleKey, 3600);
|
||||
return ['error' => 'invalid_credentials'];
|
||||
}
|
||||
|
||||
if ($user->role === 'owner') {
|
||||
$user->load(['tenant.outlets', 'tenant.users']);
|
||||
} else {
|
||||
$user->load(['tenant', 'outlet']);
|
||||
}
|
||||
|
||||
RateLimiter::clear($throttleKey);
|
||||
$user->tokens()->delete(); // logout dari device lain
|
||||
|
||||
return [
|
||||
'token' => $user->createToken('UserAuthToken')->plainTextToken,
|
||||
'user' => $user,
|
||||
];
|
||||
}
|
||||
|
||||
public function register(array $data)
|
||||
{
|
||||
return DB::transaction(function () use ($data) {
|
||||
$tenant = Tenant::create([
|
||||
'uuid' => (string) Str::uuid7(),
|
||||
'business_name' => $data['business_name'],
|
||||
'business_code' => $data['business_code'],
|
||||
'subscription_level' => 'standart',
|
||||
]);
|
||||
|
||||
$outlet = Outlet::create([
|
||||
'uuid' => (string) Str::uuid7(),
|
||||
'tenant_id' => $tenant->uuid,
|
||||
'name' => $data['business_name'],
|
||||
'is_main_outlet' => true,
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'uuid' => (string) Str::uuid7(),
|
||||
'tenant_id' => $tenant->uuid,
|
||||
'outlet_id' => $outlet->uuid,
|
||||
'name' => $data['name'],
|
||||
'phone_number' => $data['phone_number'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
'role' => 'owner',
|
||||
'is_active' => true,
|
||||
'last_sync' => Carbon::now()
|
||||
]);
|
||||
|
||||
return [
|
||||
'business_code' => $tenant->business_code,
|
||||
'user' => $user,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CheckoutService
|
||||
{
|
||||
private function generateOrderNumber()
|
||||
{
|
||||
$businessCode = config('app.current_tenant_code');
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
$dateCode = $now->format('ymd'); // Format: 260406
|
||||
|
||||
$chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
||||
$randomPart = '';
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$randomPart .= $chars[rand(0, strlen($chars) - 1)];
|
||||
}
|
||||
|
||||
$prefix = "INVC-$businessCode-$dateCode-";
|
||||
|
||||
$lastOrder = Order::where('order_number', 'like', $prefix . '%')
|
||||
->orderBy('order_number', 'desc')
|
||||
->first();
|
||||
|
||||
$nextSequence = 1;
|
||||
|
||||
if ($lastOrder) {
|
||||
$parts = explode('-', $lastOrder->order_number);
|
||||
$lastPart = end($parts);
|
||||
|
||||
if (strlen($lastPart) >= 5) {
|
||||
$lastSeqStr = substr($lastPart, -5);
|
||||
$nextSequence = (int)$lastSeqStr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
$finalSequence = $randomPart . str_pad($nextSequence, 5, '0', STR_PAD_LEFT);
|
||||
|
||||
return $prefix . $finalSequence;
|
||||
}
|
||||
|
||||
public function execute(array $data, $file)
|
||||
{
|
||||
return DB::transaction(function () use ($data, $file) {
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$businessCode = config('app.current_tenant_code');
|
||||
|
||||
$paymentProof = null;
|
||||
if ($file) {
|
||||
$filename = (string) Carbon::now()->getPreciseTimestamp(3). '.' . $file->getClientOriginalExtension();
|
||||
$paymentProof = $file->storeAs("{$businessCode}/payment_proof_orders", $filename, 'public');
|
||||
}
|
||||
|
||||
$order = Order::create([
|
||||
'uuid' => Str::uuid7(),
|
||||
'tenant_id' => $tenantId,
|
||||
'order_number' => $this->generateOrderNumber(),
|
||||
'outlet_id' => $data['outlet_id'],
|
||||
'outlet_name_snapshot' => $data['outlet_name_snapshot'],
|
||||
'outlet_phone_number_snapshot' => $data['outlet_phone_number_snapshot'],
|
||||
'outlet_address_snapshot' => $data['outlet_address_snapshot'],
|
||||
'customer_id' => $data['customer_id'],
|
||||
'customer_name_snapshot' => $data['customer_name_snapshot'],
|
||||
'customer_email_snapshot' => $data['customer_email_snapshot'] ?? null,
|
||||
'customer_phone_number_snapshot' => $data['customer_phone_number_snapshot'],
|
||||
'customer_address_snapshot' => $data['customer_address_snapshot'] ?? null,
|
||||
'source' => 'online',
|
||||
'already_read' => false,
|
||||
'order_status' => $data['order_status'],
|
||||
'delivery_type' => $data['delivery_type'],
|
||||
'delivery_preference' => $data['delivery_preference'],
|
||||
'delivery_fee_type' => $data['delivery_fee_type'],
|
||||
'delivery_fee' => $data['delivery_fee'],
|
||||
'total_delivery_fee' => $data['total_delivery_fee'],
|
||||
'total_order' => $data['total_order'],
|
||||
'total_amount' => $data['total_amount'],
|
||||
'notes' => $data['notes'],
|
||||
'payment_proof_url' => $paymentProof ? "{$businessCode}/payment_proof_orders/{$filename}" : null,
|
||||
'payment_method' => $data['payment_method'],
|
||||
]);
|
||||
|
||||
foreach ($data['items'] as $item) {
|
||||
OrderItem::create([
|
||||
'uuid' => Str::uuid7(),
|
||||
'tenant_id' => $tenantId,
|
||||
'order_id' => $order->uuid,
|
||||
'product_variant_id' => $item['product_variant_id'],
|
||||
'quantity' => $item['quantity'],
|
||||
'product_image_url_snapshot' => $item['product_image_url_snapshot'] ?? null,
|
||||
'product_name_snapshot' => $item['product_name_snapshot'],
|
||||
'product_variant_name_snapshot' => $item['product_variant_name_snapshot'] ?? null,
|
||||
'selling_price_snapshot' => $item['selling_price_snapshot'],
|
||||
'subtotal' => $item['quantity'] * $item['selling_price_snapshot'],
|
||||
]);
|
||||
}
|
||||
|
||||
return $order;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
class ConfigurationService {
|
||||
|
||||
public function getConfigurationService()
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$tenant = Tenant::with(['payment_methods' => function($q) {
|
||||
$q->whereNotNull('source_name')
|
||||
->whereNotNull('account_number')
|
||||
->whereNotNull('receipent_name');
|
||||
}])
|
||||
->where('uuid', $tenantId)
|
||||
->first();
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerAddress;
|
||||
use App\Models\Outlet;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CustomerService {
|
||||
public function login($data, $ip)
|
||||
{
|
||||
$identifier = $data['identifier'];
|
||||
$throttleKey = Str::lower($identifier) . '|' . $ip;
|
||||
|
||||
if (RateLimiter::tooManyAttempts($throttleKey, 6)) {
|
||||
$seconds = RateLimiter::availableIn($throttleKey);
|
||||
return [
|
||||
'error' => 'lockout',
|
||||
'seconds' => $seconds,
|
||||
'until' => now()->addSeconds($seconds)->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$loginField = filter_var($identifier, FILTER_VALIDATE_EMAIL) ? 'email' : 'phone_number';
|
||||
|
||||
$customer = Customer::where($loginField, $identifier)->first();
|
||||
|
||||
$storedHash = $customer->password;
|
||||
|
||||
if (str_starts_with($storedHash, '$2a$')) {
|
||||
$storedHash = str_replace('$2a$', '$2y$', $storedHash);
|
||||
}
|
||||
|
||||
if (!$customer || !Hash::check($data['password'], $storedHash)) {
|
||||
RateLimiter::hit($throttleKey, 3600);
|
||||
return ['error' => 'invalid_credentials'];
|
||||
}
|
||||
|
||||
RateLimiter::clear($throttleKey);
|
||||
$customer->tokens()->delete();
|
||||
|
||||
return [
|
||||
'token' => $customer->createToken('CustomerAuthToken')->plainTextToken,
|
||||
'customer' => $customer,
|
||||
];
|
||||
}
|
||||
|
||||
public function register($data)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$outletId = Outlet::where('tenant_id', $tenantId)
|
||||
->where('is_main_outlet', true)
|
||||
->first()
|
||||
->value('uuid');
|
||||
|
||||
Customer::create([
|
||||
'uuid' => (string) Str::uuid7(),
|
||||
'tenant_id' => $tenantId,
|
||||
'outlet_id' => $outletId,
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'phone_number' => $data['phone_number'],
|
||||
'password' => Hash::make($data['password']),
|
||||
'source' => 'online'
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateCustomer($data, $customerId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$customer = Customer::where('uuid', $customerId)
|
||||
->where('tenant_id', $tenantId)
|
||||
->first();
|
||||
|
||||
$customer->update([
|
||||
'name' => $data['name'],
|
||||
]);
|
||||
|
||||
return [
|
||||
'name' => $customer->name,
|
||||
'email' => $customer->email,
|
||||
'phone_number' => $customer->phone_number,
|
||||
];
|
||||
}
|
||||
|
||||
public function updatePassword($data, $customerId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$customer = Customer::where('uuid', $customerId)
|
||||
->where('tenant_id', $tenantId)
|
||||
->first();
|
||||
|
||||
if(!Hash::check($data['old_password'], $customer->password)) {
|
||||
return ['error' => 'invalid old password'];
|
||||
}
|
||||
|
||||
$customer->update([
|
||||
'password' => Hash::make($data['new_password'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function getCustomerAddress($customerId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$customerAddress = CustomerAddress::select([
|
||||
'uuid',
|
||||
'label',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude'
|
||||
])
|
||||
->where('customer_id', $customerId)
|
||||
->where('tenant_id', $tenantId)
|
||||
->get();
|
||||
|
||||
return $customerAddress;
|
||||
}
|
||||
|
||||
public function saveCustomerAddress($data, $customerId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
CustomerAddress::updateOrCreate([
|
||||
'uuid' => $data['uuid'],
|
||||
'customer_id' => $customerId,
|
||||
'tenant_id' => $tenantId
|
||||
], [
|
||||
'label' => $data['label'],
|
||||
'full_address' => $data['full_address'],
|
||||
'latitude' => $data['latitude'],
|
||||
'longitude' => $data['longitude']
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteCustomerAddress(string $customerId, string $id)
|
||||
{
|
||||
CustomerAddress::where('uuid', $id)
|
||||
->where('customer_id', $customerId)
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
use App\Http\Resources\Home\AllCategoriesResource;
|
||||
use App\Http\Resources\Home\CampaignByOutletResource;
|
||||
use App\Http\Resources\Home\CurrentOutletResource;
|
||||
use App\Http\Resources\Home\OtherOutletResource;
|
||||
use App\Http\Resources\Home\ProductByOutletResource;
|
||||
use App\Models\Outlet;
|
||||
use App\Models\Campaign;
|
||||
use App\Models\Category;
|
||||
use App\Models\Product;
|
||||
use App\Models\Tenant;
|
||||
use App\Traits\Multitenantable;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use function Symfony\Component\Clock\now;
|
||||
|
||||
class HomeService
|
||||
{
|
||||
use Multitenantable;
|
||||
|
||||
public function home($outletId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$tenant = Tenant::withoutGlobalScopes()
|
||||
->select(
|
||||
'online_open_time',
|
||||
'online_close_time',
|
||||
'is_close_service'
|
||||
)
|
||||
->where('uuid', $tenantId)
|
||||
->first();
|
||||
|
||||
$currentOutlet = Outlet::select([
|
||||
'uuid',
|
||||
'name',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'is_active'
|
||||
])
|
||||
->where('uuid', $outletId)
|
||||
->first();
|
||||
|
||||
if(!$currentOutlet) {
|
||||
$currentOutlet = Outlet::select([
|
||||
'uuid',
|
||||
'name',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'is_active'
|
||||
])
|
||||
->where('is_main_outlet', true)
|
||||
->first();
|
||||
}
|
||||
|
||||
$campaigns = Campaign::select([
|
||||
'campaigns.uuid',
|
||||
'campaigns.action_type',
|
||||
'campaigns.action_reference_id',
|
||||
'campaigns.server_banner_url'
|
||||
|
||||
])
|
||||
->with('outlet_campaigns')
|
||||
->whereHas('outlet_campaigns', function($q) use ($currentOutlet) {
|
||||
$q->select('outlet_campaigns.uuid')
|
||||
->where('outlet_campaigns.outlet_id', $currentOutlet->uuid);
|
||||
})
|
||||
->where('campaigns.is_active', true)
|
||||
->where(function ($q) {
|
||||
$q->where(function ($q2) {
|
||||
$q2->where('campaigns.start_date', '<=', Carbon::now()->startOfDay())
|
||||
->where('campaigns.end_date', '>=', Carbon::now()->startOfDay());
|
||||
})->orWhere(function ($q2) {
|
||||
$q2->whereNull('campaigns.start_date')
|
||||
->whereNull('campaigns.end_date');
|
||||
});
|
||||
})
|
||||
->get();
|
||||
|
||||
$categories = Category::select([
|
||||
'uuid',
|
||||
'name',
|
||||
'server_image_url'
|
||||
|
||||
])
|
||||
->get();
|
||||
|
||||
$otherOutlets = Outlet::select([
|
||||
'uuid',
|
||||
'name',
|
||||
'phone_number',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'server_banner_url',
|
||||
'is_active'
|
||||
])
|
||||
->whereNot('uuid', $currentOutlet->uuid)
|
||||
->get();
|
||||
|
||||
$productRecommendations = Product::select([
|
||||
'products.uuid',
|
||||
'products.name',
|
||||
'products.server_image_url'
|
||||
])
|
||||
->whereHas('variants', function($q) use ($currentOutlet) {
|
||||
$q->select('product_variants.is_visible_online')
|
||||
->whereHas('inventory', function($q2) use ($currentOutlet) {
|
||||
$q2->where('outlet_inventories.outlet_id', $currentOutlet->uuid);
|
||||
})
|
||||
->where('product_variants.is_visible_online', true);
|
||||
})
|
||||
->withSum(['variants as total_sold'], 'total_sold')
|
||||
->withSum(['variants as total_rating'], 'total_rating')
|
||||
->selectRaw('
|
||||
(SELECT SUM(average_rating * total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
) /
|
||||
NULLIF((SELECT SUM(total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
), 0) as average_rating
|
||||
')
|
||||
->with([
|
||||
'variants.inventory' => function ($q) use ($currentOutlet) {
|
||||
$q->select('outlet_inventories.item_id', 'selling_price')
|
||||
->where('outlet_id', $currentOutlet->uuid);
|
||||
}
|
||||
])
|
||||
->orderByDesc('total_sold')
|
||||
->orderByDesc('average_rating')
|
||||
->withCount('likes')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$products = Product::select([
|
||||
'products.uuid',
|
||||
'products.name',
|
||||
'products.server_image_url'
|
||||
])
|
||||
->whereHas('variants', function($q) use ($currentOutlet) {
|
||||
$q->select('product_variants.is_visible_online')
|
||||
->whereHas('inventory', function($q2) use ($currentOutlet) {
|
||||
$q2->where('outlet_inventories.outlet_id', $currentOutlet->uuid);
|
||||
})
|
||||
->where('product_variants.is_visible_online', true);
|
||||
})
|
||||
->withSum(['variants as total_sold'], 'total_sold')
|
||||
->withSum(['variants as total_rating'], 'total_rating')
|
||||
->selectRaw('
|
||||
(SELECT SUM(average_rating * total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
) /
|
||||
NULLIF((SELECT SUM(total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
), 0) as average_rating
|
||||
')
|
||||
->with([
|
||||
'variants.inventory' => function ($q) use ($currentOutlet) {
|
||||
$q->select('outlet_inventories.item_id', 'selling_price')
|
||||
->where('outlet_id', $currentOutlet->uuid);
|
||||
}
|
||||
])
|
||||
->orderByDesc('total_sold')
|
||||
->orderByDesc('average_rating')
|
||||
->orderByDesc('created_at')
|
||||
->withCount('likes')
|
||||
->get();
|
||||
|
||||
return [
|
||||
'operational_service' => $tenant,
|
||||
'current_outlet' => new CurrentOutletResource($currentOutlet),
|
||||
'campaign_by_outlets' => CampaignByOutletResource::collection($campaigns),
|
||||
'all_categories' => AllCategoriesResource::collection($categories),
|
||||
'other_outlets' => OtherOutletResource::collection($otherOutlets),
|
||||
'product_recommendations' => ProductByOutletResource::collection($productRecommendations),
|
||||
'all_products' => ProductByOutletResource::collection($products)
|
||||
];
|
||||
}
|
||||
|
||||
public function getOutlets()
|
||||
{
|
||||
$outlets = Outlet::select([
|
||||
'uuid',
|
||||
'name',
|
||||
'phone_number',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'server_banner_url',
|
||||
'is_active'
|
||||
])
|
||||
->whereNotNull('full_address')
|
||||
->whereNotNull('latitude')
|
||||
->whereNotNull('longitude')
|
||||
->get();
|
||||
|
||||
return OtherOutletResource::collection($outlets);
|
||||
}
|
||||
|
||||
public function getMainOutlet()
|
||||
{
|
||||
return Outlet::select([
|
||||
'uuid',
|
||||
'name',
|
||||
'phone_number',
|
||||
'full_address',
|
||||
'latitude',
|
||||
'longitude',
|
||||
])
|
||||
->where('is_main_outlet', true)
|
||||
->first();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Http\Resources\Order\OrderInfoResource;
|
||||
use App\Http\Resources\Order\OrderReportResource;
|
||||
use App\Http\Resources\Order\OrderSyncResource;
|
||||
use App\Models\Order;
|
||||
|
||||
class OrderService {
|
||||
|
||||
public function getOrderSync($orderId)
|
||||
{
|
||||
$order = Order::with([
|
||||
'customer',
|
||||
'items.variant.product.category',
|
||||
'items.variant.product.unit',
|
||||
'items.variant.inventory'
|
||||
])
|
||||
->where('uuid', $orderId)
|
||||
->first();
|
||||
|
||||
return new OrderSyncResource($order);
|
||||
}
|
||||
|
||||
public function getOrders($customerId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$orders = Order::select([
|
||||
'orders.uuid',
|
||||
'orders.order_number',
|
||||
'orders.total_amount',
|
||||
'orders.order_status',
|
||||
'orders.delivery_type',
|
||||
'orders.has_been_assessed',
|
||||
'orders.created_at'
|
||||
])
|
||||
->with(['items' => function ($q) {
|
||||
$q->select(
|
||||
'order_items.order_id',
|
||||
'order_items.product_image_url_snapshot'
|
||||
)
|
||||
->take(2);
|
||||
}])
|
||||
->withCount(['items as total_items'], 'total_items')
|
||||
->orderByDesc('orders.created_at')
|
||||
->where('orders.tenant_id', $tenantId)
|
||||
->where('orders.customer_id', $customerId)
|
||||
->where('orders.source', 'online')
|
||||
->get();
|
||||
|
||||
return OrderReportResource::collection($orders);
|
||||
}
|
||||
|
||||
public function getOrderById($customerId, $orderId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$orders = Order::select([
|
||||
'orders.uuid',
|
||||
'orders.order_number',
|
||||
'orders.created_at',
|
||||
'orders.order_status',
|
||||
'orders.is_cancellation',
|
||||
'orders.cancellation_accepted',
|
||||
'orders.approval_process',
|
||||
'orders.delivery_type',
|
||||
'orders.delivery_preference',
|
||||
'orders.outlet_name_snapshot',
|
||||
'orders.outlet_address_snapshot',
|
||||
'orders.customer_address_snapshot',
|
||||
'orders.payment_method',
|
||||
'orders.payment_proof_url',
|
||||
'orders.total_order',
|
||||
'orders.delivery_fee_type',
|
||||
'orders.delivery_fee',
|
||||
'orders.total_delivery_fee',
|
||||
'orders.total_amount'
|
||||
])
|
||||
->with(['items' => function ($q1) {
|
||||
$q1->select(
|
||||
'order_items.order_id' ,
|
||||
'order_items.product_variant_id',
|
||||
'order_items.product_image_url_snapshot',
|
||||
'order_items.product_name_snapshot',
|
||||
'order_items.product_variant_name_snapshot',
|
||||
'order_items.selling_price_snapshot',
|
||||
'order_items.quantity'
|
||||
)
|
||||
->with(['variant' => function($q2) {
|
||||
$q2->select(
|
||||
'product_variants.uuid',
|
||||
'product_variants.product_id as product_id'
|
||||
);
|
||||
}]);
|
||||
}])
|
||||
->where('orders.uuid', $orderId)
|
||||
->where('orders.tenant_id', $tenantId)
|
||||
->where('orders.customer_id', $customerId)
|
||||
->limit(1)
|
||||
->first();
|
||||
|
||||
return new OrderInfoResource($orders);
|
||||
}
|
||||
|
||||
public function cancelOrder($customerId, $orderId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$order = Order::select([
|
||||
'orders.uuid',
|
||||
'orders.outlet_id',
|
||||
'orders.updated_at'
|
||||
])
|
||||
->where('uuid', $orderId)
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('customer_id', $customerId)
|
||||
->first();
|
||||
|
||||
$order->update([
|
||||
'already_read' => false,
|
||||
'order_status' => 'canceled',
|
||||
'canceled_by' => 'customer',
|
||||
]);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
public function cancellationRequest($customerId, $orderId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$order = Order::select([
|
||||
'orders.uuid',
|
||||
'orders.outlet_id',
|
||||
'orders.updated_at'
|
||||
])
|
||||
->where('uuid', $orderId)
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('customer_id', $customerId)
|
||||
->first();
|
||||
|
||||
$order->update([
|
||||
'already_read' => false,
|
||||
'is_cancellation' => true,
|
||||
'approval_process' => 'waiting',
|
||||
]);
|
||||
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Http\Resources\Home\ProductByOutletResource;
|
||||
use App\Http\Resources\Product\ProductInfoResource;
|
||||
use App\Models\Product;
|
||||
use App\Models\Tenant;
|
||||
use App\Traits\Multitenantable;
|
||||
|
||||
class ProductService {
|
||||
use Multitenantable;
|
||||
|
||||
public function getProductById(string $uuid)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
|
||||
$tenant = Tenant::withoutGlobalScopes()
|
||||
->select('review_display_type', 'review_display_policy')
|
||||
->where('uuid', $tenantId)
|
||||
->first();
|
||||
|
||||
$product = Product::select([
|
||||
'products.uuid',
|
||||
'products.server_image_url',
|
||||
'products.name',
|
||||
'products.has_variant',
|
||||
'products.description',
|
||||
'products.unit_id'
|
||||
])
|
||||
->with(['unit' => function($q) {
|
||||
$q->select('units.uuid', 'units.name');
|
||||
},'variants' => function($q) {
|
||||
$q->select(
|
||||
'product_variants.uuid',
|
||||
'product_variants.product_id',
|
||||
'product_variants.server_image_url',
|
||||
'product_variants.total_sold',
|
||||
'product_variants.name',
|
||||
'product_variants.is_product_variant'
|
||||
)
|
||||
->where('product_variants.is_visible_online', true);
|
||||
},'variants.inventory' => function($q) {
|
||||
$q->select(
|
||||
'outlet_inventories.item_id',
|
||||
'outlet_inventories.selling_price',
|
||||
'outlet_inventories.stock_type',
|
||||
'outlet_inventories.stock'
|
||||
);
|
||||
},'variants.reviews' => function($q) {
|
||||
$q->select(
|
||||
'product_reviews.uuid',
|
||||
'product_reviews.customer_id',
|
||||
'product_reviews.product_variant_id',
|
||||
'product_reviews.rating',
|
||||
'product_reviews.comment'
|
||||
)
|
||||
->with(['customer' => function($q2) {
|
||||
$q2->select('customers.uuid','customers.name');
|
||||
}]);
|
||||
}])
|
||||
->where('uuid', $uuid)
|
||||
->first();
|
||||
|
||||
return [
|
||||
'review_display_type' => $tenant->review_display_type,
|
||||
'review_display_policy' => $tenant->review_display_policy,
|
||||
'product_info' => new ProductInfoResource($product)
|
||||
];
|
||||
}
|
||||
|
||||
public function getProductByName($currentOutletId, $name)
|
||||
{
|
||||
$products = Product::select([
|
||||
'products.uuid',
|
||||
'products.name',
|
||||
'products.server_image_url'
|
||||
])
|
||||
->whereHas('variants', function($q) use ($currentOutletId) {
|
||||
$q->select('product_variants.is_visible_online')
|
||||
->whereHas('inventory', function($q2) use ($currentOutletId) {
|
||||
$q2->where('outlet_inventories.outlet_id', $currentOutletId);
|
||||
})
|
||||
->where('product_variants.is_visible_online', true);
|
||||
})
|
||||
->withSum(['variants as total_sold'], 'total_sold')
|
||||
->withAvg(['variants as average_rating'], 'average_rating')
|
||||
->with([
|
||||
'variants.inventory' => function ($q) use ($currentOutletId) {
|
||||
$q->select('outlet_inventories.item_id', 'selling_price')
|
||||
->where('outlet_id', $currentOutletId);
|
||||
}
|
||||
])
|
||||
->where('products.name', 'like', '%'.$name.'%')
|
||||
->orderByDesc('total_sold')
|
||||
->withSum(['variants as total_rating'], 'total_rating')
|
||||
->selectRaw('
|
||||
(SELECT SUM(average_rating * total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
) /
|
||||
NULLIF((SELECT SUM(total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
), 0) as average_rating
|
||||
')
|
||||
->withCount('likes')
|
||||
->get();
|
||||
|
||||
return ProductByOutletResource::collection($products);
|
||||
}
|
||||
|
||||
public function getProductByCategory($currentOutletId, $cateogryId)
|
||||
{
|
||||
$products = Product::select([
|
||||
'products.uuid',
|
||||
'products.name',
|
||||
'products.server_image_url'
|
||||
])
|
||||
->whereHas('variants', function($q) use ($currentOutletId) {
|
||||
$q->select('product_variants.is_visible_online')
|
||||
->whereHas('inventory', function($q2) use ($currentOutletId) {
|
||||
$q2->where('outlet_inventories.outlet_id', $currentOutletId);
|
||||
})
|
||||
->where('product_variants.is_visible_online', true);
|
||||
})
|
||||
->withSum(['variants as total_sold'], 'total_sold')
|
||||
->withSum(['variants as total_rating'], 'total_rating')
|
||||
->selectRaw('
|
||||
(SELECT SUM(average_rating * total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
) /
|
||||
NULLIF((SELECT SUM(total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
), 0) as average_rating
|
||||
')
|
||||
->with([
|
||||
'variants.inventory' => function ($q) use ($currentOutletId) {
|
||||
$q->select('outlet_inventories.item_id', 'selling_price')
|
||||
->where('outlet_id', $currentOutletId);
|
||||
}
|
||||
])
|
||||
->where('products.category_id', $cateogryId)
|
||||
->orderByDesc('total_sold')
|
||||
->orderByDesc('average_rating')
|
||||
->withCount('likes')
|
||||
->get();
|
||||
|
||||
return ProductByOutletResource::collection($products);
|
||||
}
|
||||
|
||||
public function getProductBestSellerByOutlet($currentOutletId)
|
||||
{
|
||||
$products = Product::select([
|
||||
'products.uuid',
|
||||
'products.name',
|
||||
'products.server_image_url'
|
||||
])
|
||||
->whereHas('variants', function($q) use ($currentOutletId) {
|
||||
$q->select('product_variants.is_visible_online')
|
||||
->whereHas('inventory', function($q2) use ($currentOutletId) {
|
||||
$q2->where('outlet_inventories.outlet_id', $currentOutletId);
|
||||
})
|
||||
->where('product_variants.is_visible_online', true);
|
||||
})
|
||||
->withSum(['variants as total_sold'], 'total_sold')
|
||||
->withSum(['variants as total_rating'], 'total_rating')
|
||||
->selectRaw('
|
||||
(SELECT SUM(average_rating * total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
) /
|
||||
NULLIF((SELECT SUM(total_rating)
|
||||
FROM product_variants
|
||||
WHERE product_variants.product_id = products.uuid
|
||||
), 0) as average_rating
|
||||
')
|
||||
->with([
|
||||
'variants.inventory' => function ($q) use ($currentOutletId) {
|
||||
$q->select('outlet_inventories.item_id', 'selling_price')
|
||||
->where('outlet_id', $currentOutletId);
|
||||
}
|
||||
])
|
||||
->orderByDesc('total_sold')
|
||||
->orderByDesc('average_rating')
|
||||
->withCount('likes')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
return ProductByOutletResource::collection($products);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\ProductReview;
|
||||
use App\Models\ProductVariant;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ReviewService {
|
||||
|
||||
public function getProductReviewItem($orderId)
|
||||
{
|
||||
$products = OrderItem::select([
|
||||
'uuid',
|
||||
'product_variant_id',
|
||||
'product_image_url_snapshot',
|
||||
'product_name_snapshot',
|
||||
'product_variant_name_snapshot',
|
||||
|
||||
])
|
||||
->where('order_id', $orderId)
|
||||
->get();
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
||||
public function reviewProduct($data, $orderId)
|
||||
{
|
||||
$tenantId = config('app.current_tenant_id');
|
||||
DB::transaction(function () use ($data, $orderId, $tenantId) {
|
||||
foreach ($data as $item) {
|
||||
ProductReview::create([
|
||||
'uuid' => (string) Str::uuid7(),
|
||||
'tenant_id' => $tenantId,
|
||||
'customer_id' => $item['customer_id'],
|
||||
'product_variant_id' => $item['product_variant_id'],
|
||||
'rating' => $item['rating'],
|
||||
'comment' => $item['comment']
|
||||
]);
|
||||
|
||||
$productVariant = ProductVariant::lockForUpdate()
|
||||
->where('uuid', $item['product_variant_id'])
|
||||
->first();
|
||||
|
||||
if ($productVariant) {
|
||||
$newTotalRatingCount = $productVariant->total_rating + 1;
|
||||
|
||||
$sumRating = ProductReview::where('product_variant_id', $item['product_variant_id'])
|
||||
->sum('rating');
|
||||
|
||||
$newAverage = $sumRating / $newTotalRatingCount;
|
||||
|
||||
$productVariant->update([
|
||||
'total_rating' => $newTotalRatingCount,
|
||||
'average_rating' => $newAverage
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Order::where('uuid', $orderId)->update([
|
||||
'has_been_assessed' => true
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,352 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Events\DataBatchUpdated;
|
||||
use App\Models\Campaign;
|
||||
use App\Models\Category;
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerAddress;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\Outlet;
|
||||
use App\Models\OutletCampaign;
|
||||
use App\Models\OutletInventory;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductLike;
|
||||
use App\Models\ProductReview;
|
||||
use App\Models\ProductVariant;
|
||||
use App\Models\Purchase;
|
||||
use App\Models\PurchaseItem;
|
||||
use App\Models\RawMaterial;
|
||||
use App\Models\ReceiptItem;
|
||||
use App\Models\StockCard;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\SyncDelete;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\TenantPaymentMethod;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Unit;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class SyncService
|
||||
{
|
||||
protected static $columnCache = [];
|
||||
protected static $softDeleteCache = [];
|
||||
protected array $tableMap = [
|
||||
'campaigns' => Campaign::class,
|
||||
'categories' => Category::class,
|
||||
'customers' => Customer::class,
|
||||
'customer_address' => CustomerAddress::class,
|
||||
'orders' => Order::class,
|
||||
'order_items' => OrderItem::class,
|
||||
'outlets' => Outlet::class,
|
||||
'outlet_campaigns' => OutletCampaign::class,
|
||||
'outlet_inventories' => OutletInventory::class,
|
||||
'products' => Product::class,
|
||||
'product_likes' => ProductLike::class,
|
||||
'product_reviews' => ProductReview::class,
|
||||
'product_variants' => ProductVariant::class,
|
||||
'purchases' => Purchase::class,
|
||||
'purchase_items' => PurchaseItem::class,
|
||||
'raw_materials' => RawMaterial::class,
|
||||
'receipt_items' => ReceiptItem::class,
|
||||
'stock_cards' => StockCard::class,
|
||||
'suppliers' => Supplier::class,
|
||||
'sync_deletes' => SyncDelete::class,
|
||||
'tenants' => Tenant::class,
|
||||
'tenant_payment_methods'=> TenantPaymentMethod::class,
|
||||
'transactions' => Transaction::class,
|
||||
'units' => Unit::class,
|
||||
'users' => User::class,
|
||||
];
|
||||
|
||||
public function getDeltaSync($lastSync)
|
||||
{
|
||||
$tenantId = Auth::user()->tenant_id;
|
||||
return [
|
||||
'tenants' => $this->tableMap['tenants']::withoutGlobalScopes()
|
||||
->where('uuid', $tenantId)
|
||||
->where('updated_at', '>', $lastSync)
|
||||
->first(),
|
||||
'tenant_payment_methods' => $this->tableMap['tenant_payment_methods']::where('updated_at', '>', $lastSync)->get(),
|
||||
'campaigns' => $this->tableMap['campaigns']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'outlets' => $this->tableMap['outlets']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'outlet_campaigns' => $this->tableMap['outlet_campaigns']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'users' => $this->tableMap['users']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'units' => $this->tableMap['units']::where('updated_at', '>', $lastSync)->get(),
|
||||
'categories' => $this->tableMap['categories']::where('updated_at', '>', $lastSync)->get(),
|
||||
'products' => $this->tableMap['products']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'product_variants' => $this->tableMap['product_variants']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'raw_materials' => $this->tableMap['raw_materials']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'receipt_items' => $this->tableMap['receipt_items']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'outlet_inventories' => $this->tableMap['outlet_inventories']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'customers' => $this->tableMap['customers']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'customer_address' => $this->tableMap['customer_address']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'product_likes' => $this->tableMap['product_likes']::where('updated_at', '>', $lastSync)->get(),
|
||||
'product_reviews' => $this->tableMap['product_reviews']::where('updated_at', '>', $lastSync)->get(),
|
||||
'orders' => $this->tableMap['orders']::where('updated_at', '>', $lastSync)->get(),
|
||||
'order_items' => $this->tableMap['order_items']::with(['variant' => function($q) {
|
||||
$q->select('uuid','product_id')->withTrashed();
|
||||
}])->where('updated_at', '>', $lastSync)->get(),
|
||||
'suppliers' => $this->tableMap['suppliers']::withTrashed()->where('updated_at', '>', $lastSync)->get(),
|
||||
'purchases' => $this->tableMap['purchases']::where('updated_at', '>', $lastSync)->get(),
|
||||
'purchase_items' => $this->tableMap['purchase_items']::with(['item' => function (MorphTo $morphTo) {
|
||||
$morphTo->constrain([
|
||||
ProductVariant::class => fn($q) =>
|
||||
$q->select('uuid', 'product_id')->withTrashed(),
|
||||
|
||||
RawMaterial::class => fn($q) =>
|
||||
$q->select('uuid')->withTrashed(),
|
||||
]);
|
||||
}
|
||||
])->where('updated_at', '>', $lastSync)->get(),
|
||||
'transactions' => $this->tableMap['transactions']::where('updated_at', '>', $lastSync)->get(),
|
||||
'stock_cards' => $this->tableMap['stock_cards']::where('created_at', '>', $lastSync)->get(),
|
||||
'sync_deletes' => $this->tableMap['sync_deletes']::where('created_at', '>', $lastSync)->get()
|
||||
];
|
||||
}
|
||||
|
||||
public function updateServerTime(Carbon $currentTime)
|
||||
{
|
||||
Auth::user()->update(['last_sync' => $currentTime]);
|
||||
}
|
||||
|
||||
public function processBatchSync(array $payload)
|
||||
{
|
||||
$items = $payload['items'];
|
||||
$results = ['success_count' => 0, 'ignored_count' => 0, 'errors' => []];
|
||||
$changedTables = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
try {
|
||||
$tableName = $item['table'];
|
||||
$uuid = $item['local_id'];
|
||||
$action = $item['action'];
|
||||
$data = $item['data'];
|
||||
|
||||
$modelClass = $this->tableMap[$tableName] ?? null;
|
||||
|
||||
if (!$modelClass) throw new \Exception("Table {$tableName} not mapped.");
|
||||
|
||||
DB::transaction(function () use ($modelClass, $uuid, $data, $action, $tableName, &$results, &$changedTables) {
|
||||
if ($action === 'bulk_update') {
|
||||
if($tableName === 'product_variants') {
|
||||
$visibleIds = $data['visible_ids'] ?? [];
|
||||
|
||||
$modelClass::whereNotIn('uuid', $visibleIds)
|
||||
->update(['is_visible_online' => false, 'updated_at' => $data['updated_at']]);
|
||||
|
||||
$modelClass::whereIn('uuid', $visibleIds)
|
||||
->update(['is_visible_online' => true, 'updated_at' => $data['updated_at']]);
|
||||
|
||||
$results['success_count']++;
|
||||
$changedTables[] = 'product_variants';
|
||||
return;
|
||||
}
|
||||
|
||||
if($tableName === 'outlet_campaigns') {
|
||||
$ids = $data['ids'] ?? [];
|
||||
|
||||
$modelClass::whereIn('uuid', $ids)
|
||||
->update(['deleted_at' => $data['deleted_at']]);
|
||||
|
||||
$results['success_count']++;
|
||||
$changedTables = 'outlet_campaigns';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$usesSoftDeletes = $this->usesSoftDeletes($modelClass);
|
||||
|
||||
if($tableName === 'tenants') {
|
||||
$query = $modelClass::withoutGlobalScopes()->where('uuid', $uuid);
|
||||
} else {
|
||||
$query = $modelClass::where('uuid', $uuid);
|
||||
}
|
||||
|
||||
if (in_array($tableName, ['product_variants','outlet_inventories', 'stock_cards'])) {
|
||||
$query->lockForUpdate();
|
||||
}
|
||||
|
||||
if($usesSoftDeletes) {
|
||||
$query->withTrashed();
|
||||
}
|
||||
|
||||
$existing = $query->first();
|
||||
|
||||
$deltaTotalSold = 0;
|
||||
if ($tableName === 'product_variants' && isset($data['qty_sold'])) {
|
||||
$deltaTotalSold = (float) $data['qty_sold'];
|
||||
unset($data['qty_sold']);
|
||||
}
|
||||
|
||||
$shouldUpdateMetadata = true;
|
||||
if ($existing && isset($data['updated_at'])) {
|
||||
if (Carbon::parse($data['updated_at'])->lte($existing->updated_at)) {
|
||||
$shouldUpdateMetadata = false;
|
||||
$results['ignored_count']++;
|
||||
}
|
||||
}
|
||||
|
||||
if($shouldUpdateMetadata) {
|
||||
if (strtoupper($action) === 'DELETE') {
|
||||
$this->handleSoftDelete($modelClass, $uuid, $data);
|
||||
} else {
|
||||
if ($tableName === 'stock_cards') {
|
||||
$this->handleDeltaStock($data);
|
||||
$modelClass::create($data);
|
||||
} else {
|
||||
if($tableName === 'outlets' && isset($data['is_main_outlet']) && $data['is_main_outlet'] === true) {
|
||||
Outlet::whereNot('uuid', $uuid)->update(['is_main_outlet' => false]);
|
||||
}
|
||||
|
||||
$modelClass::updateOrCreate(['uuid' => $uuid], $data);
|
||||
|
||||
}
|
||||
}
|
||||
$results['success_count']++;
|
||||
}
|
||||
|
||||
if ($deltaTotalSold != 0) {
|
||||
$targetRecord = $existing ?? $modelClass::where('uuid', $uuid)->first();
|
||||
|
||||
if ($targetRecord) {
|
||||
$targetRecord->increment('total_sold', $deltaTotalSold);
|
||||
}
|
||||
}
|
||||
|
||||
if(!in_array($tableName, $changedTables)) {
|
||||
$changedTables[] = $tableName;
|
||||
}
|
||||
|
||||
}, 3);
|
||||
} catch (\Exception $e) {
|
||||
$results['errors'][] = [
|
||||
'table_name' => $item['table'],
|
||||
'local_id' => $item['local_id'],
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if($results['success_count'] > 0 && !empty($changedTables)) {
|
||||
$masterTables = [
|
||||
'tenants',
|
||||
'tenant_payment_methods',
|
||||
'outlets',
|
||||
'campaigns',
|
||||
'categories',
|
||||
'products',
|
||||
'product_variants',
|
||||
'outlet_inventories',
|
||||
'orders'
|
||||
];
|
||||
|
||||
$relevantChanges = array_intersect($changedTables, $masterTables);
|
||||
|
||||
$tenantId = Auth::user()->tenant_id;
|
||||
broadcast(new DataBatchUpdated($tenantId, array_values($relevantChanges)))->toOthers();
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
protected function tableHasColumn(string $table, string $column): bool
|
||||
{
|
||||
$cacheKey = "table_columns_{$table}";
|
||||
|
||||
if (isset(static::$columnCache[$table])) {
|
||||
return in_array($column, static::$columnCache[$table]);
|
||||
}
|
||||
|
||||
$columns = Cache::remember($cacheKey, now()->addDay(), function () use ($table) {
|
||||
return Schema::getColumnListing($table);
|
||||
});
|
||||
|
||||
static::$columnCache[$table] = $columns;
|
||||
|
||||
return in_array($column, $columns);
|
||||
}
|
||||
|
||||
protected function usesSoftDeletes($modelClass): bool
|
||||
{
|
||||
if (isset(static::$softDeleteCache[$modelClass])) {
|
||||
return static::$softDeleteCache[$modelClass];
|
||||
}
|
||||
|
||||
$uses = in_array(
|
||||
'Illuminate\Database\Eloquent\SoftDeletes',
|
||||
class_uses_recursive($modelClass)
|
||||
);
|
||||
|
||||
static::$softDeleteCache[$modelClass] = $uses;
|
||||
return $uses;
|
||||
}
|
||||
|
||||
private function handleDeltaStock($data)
|
||||
{
|
||||
$inventory = OutletInventory::withTrashed()
|
||||
->lockForUpdate()
|
||||
->where('uuid', '=', $data['outlet_inventory_id'])
|
||||
->first();
|
||||
|
||||
if (!$inventory) {
|
||||
throw new \Exception("inventory with id {$data['outlet_inventory_id']} is not found for stock synchronize");
|
||||
}
|
||||
|
||||
if($inventory->stock_type === 'unlimited') return;
|
||||
|
||||
if(isset($data['type']) && isset($data['stock_type']) && $data['stock_type'] === 'fixed') {
|
||||
$type = $data['type'];
|
||||
if (in_array($type, ['adjustment_in', 'adjustment_out'])) {
|
||||
$inventory->stock = $data['current_stock'];
|
||||
$inventory->updated_at = $data['created_at'];
|
||||
$inventory->save();
|
||||
} else if(in_array($type, ['sale', 'transfer_out'])) {
|
||||
$inventory->decrement('stock', $data['qty_change']);
|
||||
} else if(in_array($type, ['production', 'purchase', 'transfer_in'])) {
|
||||
$inventory->increment('stock', $data['qty_change']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function handleSoftDelete($modelClass, $uuid, $data)
|
||||
{
|
||||
$tableName = (new $modelClass())->getTable();
|
||||
$deletedAt = isset($data['deleted_at']) ? Carbon::parse($data['deleted_at']) : now();
|
||||
$query = $modelClass::withTrashed();
|
||||
|
||||
if (empty($data) || (!isset($data['uuid']) && count($data) === 1)) {
|
||||
$query->where('uuid', $uuid);
|
||||
} else {
|
||||
foreach ($data as $key => $value) {
|
||||
if (in_array($key, ['is_active', 'is_delete_by_owner', 'deleted_at'])) continue;
|
||||
$query->where($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$records = $query->get();
|
||||
|
||||
if ($records->isNotEmpty()) {
|
||||
foreach ($records as $record) {
|
||||
if (isset($data['is_delete_by_owner']) && $this->tableHasColumn($tableName, 'is_delete_by_owner')) {
|
||||
$record->is_delete_by_owner = $data['is_delete_by_owner'];
|
||||
}
|
||||
|
||||
if(isset($data['is_active']) && $this->tableHasColumn($tableName, 'is_active')) {
|
||||
$record->is_active = $data['is_active'];
|
||||
}
|
||||
$record->deleted_at = $deletedAt;
|
||||
$record->save();
|
||||
$record->delete();
|
||||
$record->updateQuietly(['deleted_at' => $deletedAt]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UploadService
|
||||
{
|
||||
public function uploadImage(UploadedFile $file, string $folderType): string
|
||||
{
|
||||
$tenantCode = Auth::user()->tenant->business_code;
|
||||
|
||||
$fileName = pathinfo($file->getClientOriginalName(), PATHINFO_BASENAME);
|
||||
|
||||
$targetDirectory = "{$tenantCode}/{$folderType}";
|
||||
|
||||
return $file->storeAs($targetDirectory, $fileName, 'public');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
trait ApiResponse
|
||||
{
|
||||
/**
|
||||
* Respons sukses standar
|
||||
*/
|
||||
protected function successResponse($data, $message = "Operation successful", $code = 200): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => $message,
|
||||
'data' => $data,
|
||||
'error' => null
|
||||
], $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Respons error standar
|
||||
*/
|
||||
protected function errorResponse($message = "An error occurred", $code = 400, $errorDetails = null): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => $message,
|
||||
'data' => null,
|
||||
'error' => $errorDetails
|
||||
], $code);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
trait Multitenantable
|
||||
{
|
||||
public static function bootMultitenantable()
|
||||
{
|
||||
// Otomatis isi tenant_id saat pembuatan data baru
|
||||
static::creating(function ($model) {
|
||||
if (Auth::check()) {
|
||||
if(!$model instanceof Tenant) {
|
||||
$model->tenant_id =Auth::user()->tenant_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Global Scope: Otomatis filter setiap query (select, update, delete)
|
||||
static::addGlobalScope('tenant_id', function (Builder $builder) {
|
||||
$tenantId = Auth::check() ?Auth::user()->tenant_id : config('app.current_tenant_id');
|
||||
|
||||
if($tenantId && !(static::class === Tenant::class)) {
|
||||
$builder->where($builder->getModel()->getTable() .'.tenant_id', $tenantId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Middleware\IdentifyTenant;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
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',
|
||||
channels: __DIR__.'/../routes/channels.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->alias([
|
||||
'identify.tenant' => IdentifyTenant::class
|
||||
]); //
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\TelescopeServiceProvider::class,
|
||||
];
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/reverb": "^1.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/telescope": "^5.19",
|
||||
"laravel/tinker": "^2.10.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.24",
|
||||
"laravel/sail": "^1.41",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^11.5.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"setup": [
|
||||
"composer install",
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||
"@php artisan key:generate",
|
||||
"@php artisan migrate --force",
|
||||
"npm install",
|
||||
"npm run build"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'Asia/Jakarta',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
'customer' => [
|
||||
'driver' => 'sanctum',
|
||||
'provider' => 'customers'
|
||||
]
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||
],
|
||||
'customers' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\Customer::class
|
||||
]
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the number of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Broadcaster
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default broadcaster that will be used by the
|
||||
| framework when an event needs to be broadcast. You may set this to
|
||||
| any of the connections defined in the "connections" array below.
|
||||
|
|
||||
| Supported: "reverb", "pusher", "ably", "redis", "log", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('BROADCAST_CONNECTION', 'null'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the broadcast connections that will be used
|
||||
| to broadcast events to other systems or over WebSockets. Samples of
|
||||
| each available type of connection are provided inside this array.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'reverb' => [
|
||||
'driver' => 'reverb',
|
||||
'key' => env('REVERB_APP_KEY'),
|
||||
'secret' => env('REVERB_APP_SECRET'),
|
||||
'app_id' => env('REVERB_APP_ID'),
|
||||
'options' => [
|
||||
'host' => env('REVERB_HOST'),
|
||||
'port' => env('REVERB_PORT', 443),
|
||||
'scheme' => env('REVERB_SCHEME', 'https'),
|
||||
'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'client_options' => [
|
||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
],
|
||||
],
|
||||
|
||||
'pusher' => [
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'client_options' => [
|
||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
],
|
||||
],
|
||||
|
||||
'ably' => [
|
||||
'driver' => 'ably',
|
||||
'key' => env('ABLY_KEY'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'driver' => 'log',
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'null',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane",
|
||||
| "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'stores' => [
|
||||
'database',
|
||||
'array',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?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' => ['api/*', 'sanctum/csrf-cookie', 'storage/*'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
'transaction_mode' => 'DEFERRED',
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::ATTR_EMULATE_PREPARES => true,
|
||||
PDO::ATTR_TIMEOUT => 5,
|
||||
]) : [],
|
||||
'after_contents' => [
|
||||
"SET NAMES 'utf8mb4'",
|
||||
"SET SESSION innodb_lock_wait_timeout = 5",
|
||||
"SET SESSION wait_timeout = 30",
|
||||
],
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => env('DB_SSLMODE', 'prefer'),
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
|
||||
| "deferred", "background", "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'deferred' => [
|
||||
'driver' => 'deferred',
|
||||
],
|
||||
|
||||
'background' => [
|
||||
'driver' => 'background',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'connections' => [
|
||||
'database',
|
||||
'deferred',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Reverb Server
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default server used by Reverb to handle
|
||||
| incoming messages as well as broadcasting message to all your
|
||||
| connected clients. At this time only "reverb" is supported.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('REVERB_SERVER', 'reverb'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Reverb Servers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define details for each of the supported Reverb servers.
|
||||
| Each server has its own configuration options that are defined in
|
||||
| the array below. You should ensure all the options are present.
|
||||
|
|
||||
*/
|
||||
|
||||
'servers' => [
|
||||
|
||||
'reverb' => [
|
||||
'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
|
||||
'port' => env('REVERB_SERVER_PORT', 8080),
|
||||
'path' => env('REVERB_SERVER_PATH', ''),
|
||||
'hostname' => env('REVERB_HOST'),
|
||||
'options' => [
|
||||
'tls' => [],
|
||||
],
|
||||
'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
|
||||
'scaling' => [
|
||||
'enabled' => env('REVERB_SCALING_ENABLED', false),
|
||||
'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
|
||||
'server' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'timeout' => env('REDIS_TIMEOUT', 60),
|
||||
],
|
||||
],
|
||||
'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
|
||||
'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Reverb Applications
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define how Reverb applications are managed. If you choose
|
||||
| to use the "config" provider, you may define an array of apps which
|
||||
| your server will support, including their connection credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'apps' => [
|
||||
|
||||
'provider' => 'config',
|
||||
|
||||
'apps' => [
|
||||
[
|
||||
'key' => env('REVERB_APP_KEY'),
|
||||
'secret' => env('REVERB_APP_SECRET'),
|
||||
'app_id' => env('REVERB_APP_ID'),
|
||||
'options' => [
|
||||
'host' => env('REVERB_HOST'),
|
||||
'port' => env('REVERB_PORT', 443),
|
||||
'scheme' => env('REVERB_SCHEME', 'https'),
|
||||
'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'allowed_origins' => ['*'],
|
||||
'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
|
||||
'activity_timeout' => env('REVERB_APP_ACTIVITY_TIMEOUT', 30),
|
||||
'max_connections' => env('REVERB_APP_MAX_CONNECTIONS'),
|
||||
'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10_000),
|
||||
'accept_client_events_from' => env('REVERB_APP_ACCEPT_CLIENT_EVENTS_FROM', 'members'),
|
||||
'rate_limiting' => [
|
||||
'enabled' => env('REVERB_APP_RATE_LIMITING_ENABLED', false),
|
||||
'max_attempts' => env('REVERB_APP_RATE_LIMIT_MAX_ATTEMPTS', 60),
|
||||
'decay_seconds' => env('REVERB_APP_RATE_LIMIT_DECAY_SECONDS', 60),
|
||||
'terminate_on_limit' => env('REVERB_APP_RATE_LIMIT_TERMINATE', false),
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
Sanctum::currentApplicationUrlWithPort(),
|
||||
// Sanctum::currentRequestHost(),
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'key' => env('POSTMARK_API_KEY'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_API_KEY'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain without subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue