Compare commits
No commits in common. "main" and "master" have entirely different histories.
|
@ -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
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
|
@ -0,0 +1,69 @@
|
||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=base64:XezKe3raFggOy5el7fSP8dIJ/tMs5h9XZXDnsb9yfMM=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_TIMEZONE=UTC
|
||||||
|
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=mysql
|
||||||
|
DB_HOST=db_mysql
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=laravel-cms
|
||||||
|
DB_USERNAME=laravel_user
|
||||||
|
DB_PASSWORD=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,23 @@
|
||||||
|
/.phpunit.cache
|
||||||
|
/node_modules
|
||||||
|
/public/build
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/storage/pail
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.env.production
|
||||||
|
.phpactor.json
|
||||||
|
.phpunit.result.cache
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
/auth.json
|
||||||
|
/.fleet
|
||||||
|
/.idea
|
||||||
|
/.nova
|
||||||
|
/.vscode
|
||||||
|
/.zed
|
66
README.md
66
README.md
|
@ -1,2 +1,66 @@
|
||||||
# cms-frontend
|
<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 may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
||||||
|
|
||||||
|
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)**
|
||||||
|
- **[WebReinvent](https://webreinvent.com/)**
|
||||||
|
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||||
|
- **[64 Robots](https://64robots.com)**
|
||||||
|
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||||
|
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||||
|
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||||
|
- **[Jump24](https://jump24.co.uk)**
|
||||||
|
- **[Redberry](https://redberry.international/laravel/)**
|
||||||
|
- **[Active Logic](https://activelogic.com)**
|
||||||
|
- **[byte5](https://byte5.de)**
|
||||||
|
- **[OP.GG](https://op.gg)**
|
||||||
|
|
||||||
|
## 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,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||||
|
|
||||||
|
class ConfirmPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Confirm Password Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password confirmations and
|
||||||
|
| uses a simple trait to include the behavior. You're free to explore
|
||||||
|
| this trait and override any functions that require customization.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ConfirmsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users when the intended url fails.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset emails and
|
||||||
|
| includes a trait which assists in sending these notifications from
|
||||||
|
| your application to your users. Feel free to explore this trait.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use SendsPasswordResetEmails;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
public function showLoginForm()
|
||||||
|
{
|
||||||
|
return view('login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showChangePasswordForm()
|
||||||
|
{
|
||||||
|
return view('change-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showProfile()
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
return view('pages.my-profile');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeUsername(Request $request)
|
||||||
|
{
|
||||||
|
session(['username' => $request->input('username')]);
|
||||||
|
return response()->json(['success' => true]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles the registration of new users as well as their
|
||||||
|
| validation and creation. By default this controller uses a trait to
|
||||||
|
| provide this functionality without requiring any additional code.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use RegistersUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a validator for an incoming registration request.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
|
*/
|
||||||
|
protected function validator(array $data)
|
||||||
|
{
|
||||||
|
return Validator::make($data, [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \App\Models\User
|
||||||
|
*/
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
return User::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'password' => Hash::make($data['password']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset requests
|
||||||
|
| and uses a simple trait to include this behavior. You're free to
|
||||||
|
| explore this trait and override any methods you wish to tweak.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after resetting their password.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||||
|
|
||||||
|
class VerificationController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Email Verification Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling email verification for any
|
||||||
|
| user that recently registered with the application. Emails may also
|
||||||
|
| be re-sent if the user didn't receive the original email message.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use VerifiesEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after verification.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('signed')->only('verify');
|
||||||
|
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,202 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class AuthController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the login form
|
||||||
|
*/
|
||||||
|
public function showLoginForm()
|
||||||
|
{
|
||||||
|
return view('login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle login form submission by calling the API
|
||||||
|
*/
|
||||||
|
public function login(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'username' => 'required|string',
|
||||||
|
'password' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Http::post(config('services.backend_api.url') . '/api/cms/login_password', [
|
||||||
|
'username' => $request->username,
|
||||||
|
'password' => $request->password,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
Log::info('Login API Response: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
if ($json['code'] == 200) {
|
||||||
|
$userData = [
|
||||||
|
'admin' => $json['data']['admin'] ?? null,
|
||||||
|
'access_token' => $json['data']['token'] ?? null,
|
||||||
|
'admin_uuid' => $json['data']['admin']['uuid'] ?? null,
|
||||||
|
];
|
||||||
|
Session::put('user', $userData);
|
||||||
|
Session::save();
|
||||||
|
|
||||||
|
Log::info('Session data after login: ', Session::get('user'));
|
||||||
|
|
||||||
|
// Redirect to my-profile if access_token is present
|
||||||
|
if (isset($userData['access_token']) && !empty($userData['access_token'])) {
|
||||||
|
Log::info('Access token present, redirecting to my-profile from login');
|
||||||
|
return redirect()->route('my-profile');
|
||||||
|
}
|
||||||
|
|
||||||
|
$isPasswordChanged = $json['data']['admin']['is_passwordChanged'] ?? 0;
|
||||||
|
Log::info('Login: is_passwordChanged from API = ' . $isPasswordChanged);
|
||||||
|
|
||||||
|
if ($isPasswordChanged == 1) {
|
||||||
|
Log::info('Redirecting to my-profile from login');
|
||||||
|
return redirect()->route('my-profile');
|
||||||
|
} else {
|
||||||
|
Log::info('Redirecting to change-password from login');
|
||||||
|
return redirect()->route('change-password')->with('info', 'You must change your password before accessing your profile.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return back()->withErrors(['username' => $json['message'] ?? 'Login failed.']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return back()->withErrors(['username' => $json['message'] ?? 'Login request failed.']);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Login error: ' . $e->getMessage());
|
||||||
|
return back()->withErrors(['username' => 'An error occurred: ' . $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the my-profile page
|
||||||
|
*/
|
||||||
|
public function showMyProfile()
|
||||||
|
{
|
||||||
|
$user = Session::get('user');
|
||||||
|
|
||||||
|
if (!$user || !isset($user['access_token'])) {
|
||||||
|
Log::info('No user session or access token, redirecting to login from my-profile');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view your profile.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($user['admin']) || !is_array($user['admin'])) {
|
||||||
|
Log::error('Invalid admin data in session: ', $user);
|
||||||
|
return redirect()->route('login')->with('error', 'Invalid user data. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Session data in my-profile: ', $user);
|
||||||
|
Log::info('Rendering my-profile page');
|
||||||
|
return view('pages.my-profile', compact('user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the change password form
|
||||||
|
*/
|
||||||
|
public function showChangePasswordForm()
|
||||||
|
{
|
||||||
|
if (!session()->has('user.admin_uuid')) {
|
||||||
|
Log::info('No admin_uuid in session, redirecting to login from change-password form');
|
||||||
|
return redirect()->route('login')->withErrors(['error' => 'Unauthorized access']);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Rendering change-password form');
|
||||||
|
return view('change-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle change password form submission by calling the API
|
||||||
|
*/
|
||||||
|
public function changePassword(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'admin_uuid' => 'required|string',
|
||||||
|
'password' => 'required|string|min:8|confirmed',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$url = "{$this->apiBaseUrl}/cms/login_changePassword";
|
||||||
|
$csrfToken = $request->session()->token();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'X-CSRF-TOKEN' => $csrfToken,
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . session('user.access_token'),
|
||||||
|
])->post($url, [
|
||||||
|
'admin_uuid' => $request->input('admin_uuid'),
|
||||||
|
'password' => $request->input('password'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = $response->json();
|
||||||
|
|
||||||
|
Log::info('Change Password API Response: ', $data);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($data['code']) && $data['code'] === 200) {
|
||||||
|
$user = Session::get('user');
|
||||||
|
|
||||||
|
// Update access token from API response
|
||||||
|
if (isset($data['token'])) {
|
||||||
|
$user['access_token'] = $data['token'];
|
||||||
|
} elseif (isset($data['data']['access_token'])) {
|
||||||
|
$user['access_token'] = $data['data']['access_token'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update admin data with the latest from API
|
||||||
|
if (isset($data['admin'])) {
|
||||||
|
$user['admin'] = $data['admin'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::put('user', $user);
|
||||||
|
Session::save();
|
||||||
|
|
||||||
|
Log::info('Updated Session after password change: ', Session::get('user'));
|
||||||
|
Log::info('Redirecting to my-profile from changePassword');
|
||||||
|
|
||||||
|
// Immediately redirect to my-profile
|
||||||
|
return redirect()->route('my-profile')->with('success', $data['message'] ?? 'Password changed successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Change password failed, redirecting back');
|
||||||
|
return redirect()->back()->withErrors(['error' => $data['message'] ?? 'Failed to change password']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Change Password Exception: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->withErrors(['error' => 'Password change request failed: ' . $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle logout by calling the API
|
||||||
|
*/
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
$url = "{$this->apiBaseUrl}/logout_cms";
|
||||||
|
$csrfToken = $request->session()->token();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Http::withHeaders([
|
||||||
|
'X-CSRF-TOKEN' => $csrfToken,
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . session('user.access_token'),
|
||||||
|
])->post($url);
|
||||||
|
|
||||||
|
session()->flush();
|
||||||
|
Log::info('Logged out, redirecting to login');
|
||||||
|
return redirect()->route('login')->with('success', 'Logged out successfully');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Logout Exception: ' . $e->getMessage());
|
||||||
|
session()->flush();
|
||||||
|
return redirect()->route('login')->with('success', 'Logged out successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,262 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class CardMemberController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from card-member');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view card members.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$pageSize = 5; // Fixed at 5 per page as per sample
|
||||||
|
$search = $request->input('_search', null);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/member", [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $search,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response: ', $response->json());
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
Log::info("Card Member API Response (Page {$page}): ", $json);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$members = array_map(function ($member) {
|
||||||
|
Log::info('Processing card member record: ', $member);
|
||||||
|
return [
|
||||||
|
'id' => $member['lcard_uuid'] ?? null,
|
||||||
|
'cardNumber' => $member['card_number'] ?? '',
|
||||||
|
'firstName' => $member['firstname'] ?? '',
|
||||||
|
'lastName' => $member['lastname'] ?? '',
|
||||||
|
'birthday' => $member['birthdate'] ?? '',
|
||||||
|
'cardType' => $member['card_type'] ?? '',
|
||||||
|
'status' => $member['status'] ? 'Active' : 'Inactive',
|
||||||
|
'is_locked' => $member['is_locked'] ?? 0, // Add is_locked field
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($members);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $pageSize);
|
||||||
|
} else {
|
||||||
|
Log::warning('No card member data found or invalid API response: ', $json);
|
||||||
|
$members = [];
|
||||||
|
$total = 0;
|
||||||
|
$lastPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.member management.card-member', [
|
||||||
|
'members' => $members,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching card member data: ' . $e->getMessage());
|
||||||
|
return view('pages.member management.card-member', [
|
||||||
|
'members' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function lockedAccounts(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Force a log to confirm the method is reached
|
||||||
|
Log::debug('Entering lockedAccounts method', ['request' => $request->all()]);
|
||||||
|
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::warning('No access token found, redirecting to login from locked-account');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view locked accounts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::debug('Access token found', ['access_token' => $accessToken]);
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$pageSize = 5;
|
||||||
|
$search = $request->input('_search', null);
|
||||||
|
|
||||||
|
Log::debug('Making API call to fetch locked accounts', [
|
||||||
|
'url' => "{$this->apiBaseUrl}/cms/member",
|
||||||
|
'params' => ['page' => $page, 'page_size' => $pageSize, '_search' => $search, '_locked' => 1],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/member", [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $search,
|
||||||
|
'_locked' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Log::debug('API response received', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $response->body(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response', ['response' => $response->json()]);
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('Locked Account API Raw Response', ['response' => $json]);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$members = array_map(function ($member) {
|
||||||
|
Log::info('Processing locked account record', ['member' => $member]);
|
||||||
|
return [
|
||||||
|
'id' => $member['lcard_uuid'] ?? null,
|
||||||
|
'cardNumber' => $member['card_number'] ?? '',
|
||||||
|
'firstName' => $member['firstname'] ?? '',
|
||||||
|
'lastName' => $member['lastname'] ?? '',
|
||||||
|
'birthday' => $member['birthdate'] ?? '',
|
||||||
|
'cardType' => $member['card_type'] ?? '',
|
||||||
|
'status' => $member['status'] ? 'Active' : 'Inactive',
|
||||||
|
'is_locked' => $member['is_locked'] ?? 0,
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($members);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $pageSize);
|
||||||
|
} else {
|
||||||
|
Log::warning('No locked account data found or invalid API response', ['response' => $json]);
|
||||||
|
$members = [];
|
||||||
|
$total = 0;
|
||||||
|
$lastPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::debug('Rendering view with data', [
|
||||||
|
'members' => $members,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('pages.member management.locked-account', [
|
||||||
|
'members' => $members,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error in lockedAccounts method', [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
return view('pages.member management.locked-account', [
|
||||||
|
'members' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view a card member.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/member/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$member = [
|
||||||
|
'id' => $json['data']['lcard_uuid'] ?? null,
|
||||||
|
'cardNumber' => $json['data']['card_number'] ?? '',
|
||||||
|
'firstName' => $json['data']['firstname'] ?? '',
|
||||||
|
'lastName' => $json['data']['lastname'] ?? '',
|
||||||
|
'birthday' => $json['data']['birthdate'] ?? '',
|
||||||
|
'cardType' => $json['data']['card_type'] ?? '',
|
||||||
|
'status' => $json['data']['status'] ? 'Active' : 'Inactive',
|
||||||
|
'is_locked' => $json['data']['is_locked'] ?? 0, // Add is_locked field
|
||||||
|
];
|
||||||
|
|
||||||
|
// Determine the view based on the referring route
|
||||||
|
$previousUrl = url()->previous();
|
||||||
|
if (str_contains($previousUrl, 'locked-account')) {
|
||||||
|
return view('pages.locked-account-view', ['member' => $member]);
|
||||||
|
}
|
||||||
|
return view('pages.card-member-view', ['member' => $member]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No card member found or invalid API response: ', $json);
|
||||||
|
return redirect()->back()->with('error', 'Card member not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching card member for view: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while loading the card member.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activate($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to activate an account.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/memberActivate/{$uuid}");
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return redirect()->route('locked-account')->with('success', 'Account activated successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to activate account: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to activate account. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error activating account: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while activating the account.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,414 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class CardTypeController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api/cms';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from card-types');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view card types.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$pageSize = 5;
|
||||||
|
$search = $request->input('_search', null);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cardType", [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $search,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response: ', $response->json());
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$cardTypes = array_map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item['cardtype_uuid'] ?? null,
|
||||||
|
'cardCode' => $item['code'] ?? '',
|
||||||
|
'cardTypeDescription' => $item['description'] ?? '',
|
||||||
|
'cardTypeShortDescription' => $item['short_description'] ?? '',
|
||||||
|
'cardTypeImage' => $item['image'] ?? '',
|
||||||
|
'virtualCardFontColor' => $item['virtual_card_font_color'] ?? '',
|
||||||
|
'cardTypeCoverImage' => $item['bg_image'] ?? '',
|
||||||
|
'idNumberRequired' => $item['id_number'] ? 'Yes' : 'No',
|
||||||
|
'idNumberDescription' => $item['id_number_description'] ?? '',
|
||||||
|
'termsAndConditions' => $item['terms_and_conditions'] ?? '',
|
||||||
|
'faqs' => $item['faqs'] ?? '',
|
||||||
|
'type' => $item['type'] ?? '',
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($cardTypes);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $pageSize);
|
||||||
|
} else {
|
||||||
|
Log::warning('No card types data found or invalid API response: ', $json);
|
||||||
|
$cardTypes = [];
|
||||||
|
$total = 0;
|
||||||
|
$lastPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.about us.card-types', [
|
||||||
|
'cardTypes' => $cardTypes,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching card types: ' . $e->getMessage());
|
||||||
|
return view('pages.about us.card-types', [
|
||||||
|
'cardTypes' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a card type.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.add-card-types', [
|
||||||
|
'fontColors' => ['White', 'Black'],
|
||||||
|
'idNumberOptions' => ['Yes', 'No'],
|
||||||
|
'cardTypes' => ['Visa', 'MasterCard', 'Amex'],
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error loading create card type page: ' . $e->getMessage());
|
||||||
|
return view('pages.add-card-types', [
|
||||||
|
'fontColors' => ['White', 'Black'],
|
||||||
|
'idNumberOptions' => ['Yes', 'No'],
|
||||||
|
'cardTypes' => ['Visa', 'MasterCard', 'Amex'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a card type.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'code' => 'required|string|max:50',
|
||||||
|
'type' => 'required|in:Visa,MasterCard,Amex',
|
||||||
|
'description' => 'required|string|max:255',
|
||||||
|
'short_description' => 'required|string|max:100',
|
||||||
|
'image' => 'nullable|file|mimes:jpeg,png,jpg,gif|max:2048',
|
||||||
|
'bg_image' => 'nullable|file|mimes:jpeg,png,jpg,gif|max:2048',
|
||||||
|
'virtual_card_font_color' => 'required|in:White,Black',
|
||||||
|
'id_number' => 'required|in:Yes,No',
|
||||||
|
'id_number_description' => 'nullable|string|max:255',
|
||||||
|
'terms_and_conditions' => 'required|string',
|
||||||
|
'faqs' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'code' => $request->input('code'),
|
||||||
|
'type' => $request->input('type'),
|
||||||
|
'description' => $request->input('description'),
|
||||||
|
'short_description' => $request->input('short_description'),
|
||||||
|
'virtual_card_font_color' => $request->input('virtual_card_font_color'),
|
||||||
|
'id_number' => $request->input('id_number') === 'Yes' ? 1 : 0,
|
||||||
|
'id_number_description' => $request->input('id_number_description', ''),
|
||||||
|
'terms_and_conditions' => $request->input('terms_and_conditions'),
|
||||||
|
'faqs' => $request->input('faqs'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$client = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->hasFile('image')) {
|
||||||
|
$image = $request->file('image');
|
||||||
|
$client = $client->attach('image', file_get_contents($image->getPathname()), $image->getClientOriginalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('bg_image')) {
|
||||||
|
$bgImage = $request->file('bg_image');
|
||||||
|
$client = $client->attach('bg_image', file_get_contents($bgImage->getPathname()), $bgImage->getClientOriginalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->post("{$this->apiBaseUrl}/cardType", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('API response for creating card type: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Card type created successfully: ', $json);
|
||||||
|
return redirect()->route('card-types')->with('success', $json['message'] ?? 'Card type added successfully.');
|
||||||
|
} else {
|
||||||
|
$errorMessage = $json['message'] ?? 'Failed to add card type. Please try again.';
|
||||||
|
if (isset($json['errors'])) {
|
||||||
|
$errorMessage .= ' Errors: ' . json_encode($json['errors']);
|
||||||
|
}
|
||||||
|
throw new \Exception($errorMessage);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating card type: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->withErrors(['error' => 'An error occurred while adding the card type: ' . $e->getMessage()])->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view a card type.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cardType/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$cardType = [
|
||||||
|
'id' => $json['data']['cardtype_uuid'] ?? null,
|
||||||
|
'cardCode' => $json['data']['code'] ?? '',
|
||||||
|
'cardTypeDescription' => $json['data']['description'] ?? '',
|
||||||
|
'cardTypeShortDescription' => $json['data']['short_description'] ?? '',
|
||||||
|
'cardTypeImage' => $json['data']['image'] ?? '',
|
||||||
|
'virtualCardFontColor' => $json['data']['virtual_card_font_color'] ?? '',
|
||||||
|
'cardTypeCoverImage' => $json['data']['bg_image'] ?? '',
|
||||||
|
'idNumberRequired' => $json['data']['id_number'] ? 'Yes' : 'No',
|
||||||
|
'idNumberDescription' => $json['data']['id_number_description'] ?? '',
|
||||||
|
'termsAndConditions' => $json['data']['terms_and_conditions'] ?? '',
|
||||||
|
'faqs' => $json['data']['faqs'] ?? '',
|
||||||
|
'type' => $json['data']['type'] ?? '',
|
||||||
|
];
|
||||||
|
return view('pages.view-card-types', ['cardType' => $cardType]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No card type found or invalid API response: ', $json);
|
||||||
|
return redirect()->back()->with('error', 'Card type not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching card type for view: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while loading the card type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to edit a card type.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cardType/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$cardType = [
|
||||||
|
'id' => $json['data']['cardtype_uuid'] ?? null,
|
||||||
|
'cardCode' => $json['data']['code'] ?? '',
|
||||||
|
'cardTypeDescription' => $json['data']['description'] ?? '',
|
||||||
|
'cardTypeShortDescription' => $json['data']['short_description'] ?? '',
|
||||||
|
'cardTypeImage' => $json['data']['image'] ?? '',
|
||||||
|
'virtualCardFontColor' => $json['data']['virtual_card_font_color'] ?? '',
|
||||||
|
'cardTypeCoverImage' => $json['data']['bg_image'] ?? '',
|
||||||
|
'idNumberRequired' => $json['data']['id_number'] ? 'Yes' : 'No',
|
||||||
|
'idNumberDescription' => $json['data']['id_number_description'] ?? '',
|
||||||
|
'termsAndConditions' => $json['data']['terms_and_conditions'] ?? '',
|
||||||
|
'faqs' => $json['data']['faqs'] ?? '',
|
||||||
|
'type' => $json['data']['type'] ?? '',
|
||||||
|
];
|
||||||
|
return view('pages.edit-card-types', [
|
||||||
|
'cardType' => $cardType,
|
||||||
|
'fontColors' => ['White', 'Black'],
|
||||||
|
'idNumberOptions' => ['Yes', 'No'],
|
||||||
|
'cardTypes' => ['Visa', 'MasterCard', 'Amex'],
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No card type found or invalid API response: ', $json);
|
||||||
|
return redirect()->back()->with('error', 'Card type not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching card type for edit: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while loading the card type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to update a card type.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'code' => 'required|string|max:50',
|
||||||
|
'type' => 'required|in:Visa,MasterCard,Amex',
|
||||||
|
'description' => 'required|string|max:255',
|
||||||
|
'short_description' => 'required|string|max:100',
|
||||||
|
'image' => 'nullable|file|mimes:jpeg,png,jpg,gif|max:2048',
|
||||||
|
'bg_image' => 'nullable|file|mimes:jpeg,png,jpg,gif|max:2048',
|
||||||
|
'virtual_card_font_color' => 'required|in:White,Black',
|
||||||
|
'id_number' => 'required|in:Yes,No',
|
||||||
|
'id_number_description' => 'nullable|string|max:255',
|
||||||
|
'terms_and_conditions' => 'required|string',
|
||||||
|
'faqs' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'code' => $request->input('code'),
|
||||||
|
'type' => $request->input('type'),
|
||||||
|
'description' => $request->input('description'),
|
||||||
|
'short_description' => $request->input('short_description'),
|
||||||
|
'virtual_card_font_color' => $request->input('virtual_card_font_color'),
|
||||||
|
'id_number' => $request->input('id_number') === 'Yes' ? 1 : 0,
|
||||||
|
'id_number_description' => $request->input('id_number_description', ''),
|
||||||
|
'terms_and_conditions' => $request->input('terms_and_conditions'),
|
||||||
|
'faqs' => $request->input('faqs'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$client = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->hasFile('image')) {
|
||||||
|
$image = $request->file('image');
|
||||||
|
$client = $client->attach('image', file_get_contents($image->getPathname()), $image->getClientOriginalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->hasFile('bg_image')) {
|
||||||
|
$bgImage = $request->file('bg_image');
|
||||||
|
$client = $client->attach('bg_image', file_get_contents($bgImage->getPathname()), $bgImage->getClientOriginalName());
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->post("{$this->apiBaseUrl}/cardTypeUpdate/{$uuid}", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('API response for updating card type: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Card type updated successfully: ', $json);
|
||||||
|
return redirect()->route('card-types')->with('success', $json['message'] ?? 'Card type updated successfully.');
|
||||||
|
} else {
|
||||||
|
$errorMessage = $json['message'] ?? 'Failed to update card type. Please try again.';
|
||||||
|
if (isset($json['errors'])) {
|
||||||
|
$errorMessage .= ' Errors: ' . json_encode($json['errors']);
|
||||||
|
}
|
||||||
|
return redirect()->back()->withErrors(['error' => $errorMessage]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error updating card type: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->withErrors(['error' => 'An error occurred while updating the card type: ' . $e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete a card type.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/cardType/{$uuid}");
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Card type deleted successfully: ' . $uuid);
|
||||||
|
return redirect()->route('card-types')->with('success', 'Card type deleted successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to delete card type: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to delete card type. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error deleting card type: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting the card type.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchDelete(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete card types.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$uuids = $request->input('cardtype_uuid', []);
|
||||||
|
|
||||||
|
if (empty($uuids)) {
|
||||||
|
return redirect()->back()->with('error', 'No card types selected for deletion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/cardTypeBatchDelete", [
|
||||||
|
'cardtype_uuid' => $uuids,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Card types batch deleted successfully: ', $uuids);
|
||||||
|
return redirect()->route('card-types')->with('success', 'Selected card types deleted successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to batch delete card types: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to delete card types. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error batch deleting card types: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting the card types.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class ChangePasswordController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->apiBaseUrl = env('API_BASE_URL', 'http://your-backend-api-url');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showChangePasswordForm()
|
||||||
|
{
|
||||||
|
return view('change-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatePassword(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'password' => 'required|min:8|confirmed',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$adminId = Session::get('admin_id');
|
||||||
|
$apiToken = Session::get('api_token');
|
||||||
|
|
||||||
|
if (!$adminId || !$apiToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'You must be logged in to change your password');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withToken($apiToken)
|
||||||
|
->get("{$this->apiBaseUrl}/api/admin/{$adminId}");
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
return redirect()->back()->with('error', 'Unable to fetch admin data. Please try again later.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$admin = $response->json();
|
||||||
|
|
||||||
|
if (!$admin) {
|
||||||
|
return redirect()->route('login')->with('error', 'Admin not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$updateResponse = Http::withToken($apiToken)
|
||||||
|
->put("{$this->apiBaseUrl}/api/admin/{$adminId}", [
|
||||||
|
'password' => bcrypt($request->password),
|
||||||
|
'is_passwordChanged' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($updateResponse->failed()) {
|
||||||
|
return redirect()->back()->with('error', 'Failed to update password. Please try again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('my-profile')->with('success', 'Password updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to fetch and display admin profile data
|
||||||
|
public function showProfile()
|
||||||
|
{
|
||||||
|
$adminId = Session::get('admin_id');
|
||||||
|
$apiToken = Session::get('api_token');
|
||||||
|
|
||||||
|
if (!$adminId || !$apiToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'You must be logged in to view your profile');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withToken($apiToken)
|
||||||
|
->get("{$this->apiBaseUrl}/api/admin/{$adminId}");
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
return redirect()->back()->with('error', 'Unable to fetch profile data. Please try again later.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$admin = $response->json();
|
||||||
|
|
||||||
|
if (!$admin) {
|
||||||
|
return redirect()->route('login')->with('error', 'Admin not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('my-profile', ['admin' => $admin]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, ValidatesRequests;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Support\Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('home');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,284 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class LockedAccountController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the main page with locked accounts.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Force a log to confirm the method is reached
|
||||||
|
Log::debug('Entering LockedAccountController index method', ['request' => $request->all()]);
|
||||||
|
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::warning('No access token found, redirecting to login from locked-accounts');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view locked accounts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::debug('Access token found', ['access_token' => $accessToken]);
|
||||||
|
|
||||||
|
// Prepare query parameters
|
||||||
|
$params = [
|
||||||
|
'page' => $request->input('page', 1),
|
||||||
|
'page_size' => $request->input('page_size', 5), // Match CardMemberController's default
|
||||||
|
'_search' => $request->input('_search', null),
|
||||||
|
'status' => $request->input('status', null),
|
||||||
|
'_locked' => 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::debug('Making API call to fetch locked accounts', [
|
||||||
|
'url' => "{$this->apiBaseUrl}/cms/member",
|
||||||
|
'params' => $params,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/member", $params);
|
||||||
|
|
||||||
|
Log::debug('API response received', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $response->body(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response', ['response' => $response->json()]);
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('Locked Accounts API Raw Response', ['response' => $json]);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$accounts = array_map(function ($account) {
|
||||||
|
Log::info('Processing locked account record', ['account' => $account]);
|
||||||
|
return [
|
||||||
|
'id' => $account['lcard_uuid'] ?? null,
|
||||||
|
'cardNumber' => $account['card_number'] ?? '',
|
||||||
|
'firstName' => $account['firstname'] ?? '',
|
||||||
|
'lastName' => $account['lastname'] ?? '',
|
||||||
|
'birthday' => $account['birthdate'] ?? '',
|
||||||
|
'cardType' => $account['card_type'] ?? '',
|
||||||
|
'status' => $account['status'] ? 'Active' : 'Inactive',
|
||||||
|
'is_locked' => $account['is_locked'] ?? 1, // Ensure locked status
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($accounts);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $params['page_size']);
|
||||||
|
} else {
|
||||||
|
Log::warning('No locked account data found or invalid API response', ['response' => $json]);
|
||||||
|
$accounts = [];
|
||||||
|
$total = 0;
|
||||||
|
$lastPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::debug('Rendering view with data', [
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'currentPage' => $params['page'],
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'params' => $params,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('pages.member management.locked-accounts', [
|
||||||
|
'members' => $accounts, // Match naming convention with CardMemberController
|
||||||
|
'currentPage' => $params['page'],
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'search' => $params['_search'],
|
||||||
|
'params' => $params, // Include params for view compatibility
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error in LockedAccountController index method', [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
return view('pages.member management.locked-accounts', [
|
||||||
|
'members' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
'search' => $params['_search'] ?? null,
|
||||||
|
'params' => $params ?? [
|
||||||
|
'page' => 1,
|
||||||
|
'page_size' => 5,
|
||||||
|
'_search' => null,
|
||||||
|
'status' => null,
|
||||||
|
'_locked' => 1,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activate a locked account.
|
||||||
|
*
|
||||||
|
* @param string $uuid
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function activate($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::warning('No access token found, redirecting to login from activate account');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to activate an account.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::debug('Making API call to activate account', [
|
||||||
|
'url' => "{$this->apiBaseUrl}/cms/memberActivate/{$uuid}",
|
||||||
|
'uuid' => $uuid,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/memberActivate/{$uuid}");
|
||||||
|
|
||||||
|
Log::debug('Activate API response received', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'body' => $response->body(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return redirect()->route('locked-accounts')->with('success', 'Account activated successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to activate account', ['uuid' => $uuid, 'response' => $response->json()]);
|
||||||
|
return redirect()->route('locked-accounts')->with('error', $response->json()['message'] ?? 'Failed to activate account. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error activating account', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
return redirect()->route('locked-accounts')->with('error', 'An error occurred while activating the account.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Verify session data
|
||||||
|
$user = Session::get('user');
|
||||||
|
Log::debug('Session user data', ['user' => $user]);
|
||||||
|
|
||||||
|
if (!$user || !isset($user['access_token'])) {
|
||||||
|
Log::warning('No user or access token found in session', ['uuid' => $uuid]);
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view the account.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$accessToken = $user['access_token'];
|
||||||
|
Log::debug('Access token in show method', ['access_token' => $accessToken]);
|
||||||
|
|
||||||
|
// Log the API request details
|
||||||
|
$apiUrl = "{$this->apiBaseUrl}/cms/member/{$uuid}";
|
||||||
|
Log::debug('Making API call to fetch locked account details', [
|
||||||
|
'url' => $apiUrl,
|
||||||
|
'uuid' => $uuid,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Make the API call
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->timeout(10)->get($apiUrl);
|
||||||
|
|
||||||
|
// Log the raw response
|
||||||
|
Log::debug('Show API response received', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'headers' => $response->headers(),
|
||||||
|
'body' => $response->body(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Handle specific HTTP status codes
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'response' => $response->json(),
|
||||||
|
]);
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->status() === 404) {
|
||||||
|
Log::warning('Account not found in API', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'response' => $response->json(),
|
||||||
|
]);
|
||||||
|
return redirect()->route('locked-accounts')->with('error', 'The requested account does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response->successful()) {
|
||||||
|
Log::error('API request failed', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'status' => $response->status(),
|
||||||
|
'response' => $response->json(),
|
||||||
|
]);
|
||||||
|
return redirect()->route('locked-accounts')->with('error', 'Failed to fetch account data from the server. Status: ' . $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the response
|
||||||
|
$json = $response->json();
|
||||||
|
Log::debug('Parsed API response', ['json' => $json]);
|
||||||
|
|
||||||
|
if (!isset($json['data']) || !is_array($json['data'])) {
|
||||||
|
Log::warning('Invalid or missing data in API response', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'response' => $json,
|
||||||
|
]);
|
||||||
|
return redirect()->route('locked-accounts')->with('error', 'Invalid account data received from the server.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map the data
|
||||||
|
$account = [
|
||||||
|
'id' => $json['data']['lcard_uuid'] ?? null,
|
||||||
|
'cardNumber' => $json['data']['card_number'] ?? '',
|
||||||
|
'firstName' => $json['data']['firstname'] ?? '',
|
||||||
|
'lastName' => $json['data']['lastname'] ?? '',
|
||||||
|
'birthday' => $json['data']['birthdate'] ?? '',
|
||||||
|
'cardType' => $json['data']['card_type'] ?? '',
|
||||||
|
'status' => $json['data']['status'] ? 'Active' : 'Inactive',
|
||||||
|
'is_locked' => $json['data']['is_locked'] ?? 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::debug('Mapped account data', ['account' => $account]);
|
||||||
|
|
||||||
|
return view('pages.locked-account-view', [
|
||||||
|
'member' => $account,
|
||||||
|
]);
|
||||||
|
} catch (\Illuminate\Http\Client\ConnectionException $e) {
|
||||||
|
Log::error('Connection error in LockedAccountController show method', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
return redirect()->route('locked-accounts')->with('error', 'Unable to connect to the server. Please try again later.');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Unexpected error in LockedAccountController show method', [
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
return redirect()->route('locked-accounts')->with('error', 'An unexpected error occurred while fetching the account: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class NotificationController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from notification');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view notifications.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch all notifications directly from the API
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/notification");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info("Response from index endpoint: ", $json);
|
||||||
|
|
||||||
|
$notifications = [];
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response for index endpoint: ', $json);
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$notifications = array_map(function ($notification) {
|
||||||
|
return [
|
||||||
|
'id' => $notification['id'] ?? null,
|
||||||
|
'subject' => $notification['subject'] ?? 'Untitled',
|
||||||
|
'description' => $notification['description'] ?? '',
|
||||||
|
'isScheduled' => $notification['trigger_schedule'] ? 'Scheduled' : 'Not Scheduled',
|
||||||
|
'schedule' => $notification['trigger_schedule'] ?? '',
|
||||||
|
'expiration' => $notification['expiration_date'] ?? '',
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to fetch notifications: ', $json);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update session with the fetched notification IDs (optional, for future use)
|
||||||
|
$notificationIds = array_column($notifications, 'id');
|
||||||
|
Session::put('notification_ids', $notificationIds);
|
||||||
|
|
||||||
|
return view('pages.notification', [
|
||||||
|
'notifications' => $notifications,
|
||||||
|
])->with('error', empty($notifications) ? 'No notification data available. Please create a new notification.' : '');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching notification data: ' . $e->getMessage());
|
||||||
|
return view('pages.notification', [
|
||||||
|
'notifications' => [],
|
||||||
|
])->with('error', 'An error occurred while fetching notifications: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('pages.add-notification');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a notification.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'subject' => $request->input('subject'),
|
||||||
|
'description' => $request->input('description'),
|
||||||
|
'schedule' => $request->input('schedule') ?: null,
|
||||||
|
'expiration' => $request->input('expiration') ?: null,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/notification", $data);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return redirect()->route('notification')->with('success', 'Notification created successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to create notification: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to create notification. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating notification: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while creating the notification: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return redirect()->route('notification')->with('error', 'Edit functionality is not available due to backend limitations.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
return redirect()->route('notification')->with('error', 'Update functionality is not available due to backend limitations.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return redirect()->route('notification')->with('error', 'View functionality is not available due to backend limitations.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
return redirect()->route('notification')->with('error', 'Delete functionality is not available due to backend limitations.');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,339 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class PhotoSliderController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from photo-slider');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view photo sliders.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$pageSize = 5;
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/photoSlider", [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $request->input('_search', null),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response: ', $response->json());
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
Log::info("PhotoSlider API Response (Page {$page}): ", $json);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$sliders = array_map(function ($slider) {
|
||||||
|
Log::info('Processing photo slider record: ', $slider);
|
||||||
|
return [
|
||||||
|
'photoslider_uuid' => $slider['photoslider_uuid'] ?? $slider['id'] ?? null,
|
||||||
|
'title' => $slider['title'] ?? 'Untitled',
|
||||||
|
'type' => $slider['promo_type'] ?? 'Unknown',
|
||||||
|
'startDate' => $slider['date_start'] ?? null,
|
||||||
|
'endDate' => $slider['date_end'] ?? null,
|
||||||
|
'isActive' => $slider['is_active'] ?? 0,
|
||||||
|
'image' => $slider['image'] ?? null, // Include image field
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($sliders);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $pageSize);
|
||||||
|
|
||||||
|
return view('pages.home page.photo-slider', [
|
||||||
|
'sliders' => $sliders,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No photo slider data found or invalid API response: ', $json);
|
||||||
|
return view('pages.home page.photo-slider', [
|
||||||
|
'sliders' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching photo slider data: ' . $e->getMessage());
|
||||||
|
return view('pages.home page.photo-slider', [
|
||||||
|
'sliders' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('pages.photo-slider-create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a photo slider.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the request
|
||||||
|
$request->validate([
|
||||||
|
'image' => 'required|file|mimes:jpeg,png,jpg,gif|max:2048', // Adjust max size as needed
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => $request->input('title'),
|
||||||
|
'description' => $request->input('description'),
|
||||||
|
'promo_type' => $request->input('type'),
|
||||||
|
'date_start' => $request->input('startDate'),
|
||||||
|
'date_end' => $request->input('endDate'),
|
||||||
|
'is_active' => $request->input('isActive', 0),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Attach the image file
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->attach(
|
||||||
|
'image', file_get_contents($request->file('image')->getRealPath()), $request->file('image')->getClientOriginalName()
|
||||||
|
)->post("{$this->apiBaseUrl}/cms/photoSlider", $data);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return redirect()->route('photo-slider')->with('success', 'Photo slider created successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to create photo slider: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to create photo slider. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating photo slider: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while creating the photo slider: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to edit a photo slider.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/photoSlider/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$slider = [
|
||||||
|
'photo_slider_uuid' => $json['data']['photoslider_uuid'] ?? $json['data']['id'] ?? null,
|
||||||
|
'title' => $json['data']['title'] ?? 'Untitled',
|
||||||
|
'description' => $json['data']['description'] ?? '',
|
||||||
|
'type' => $json['data']['promo_type'] ?? 'Unknown',
|
||||||
|
'startDate' => $json['data']['date_start'] ?? null,
|
||||||
|
'endDate' => $json['data']['date_end'] ?? null,
|
||||||
|
'isActive' => $json['data']['is_active'] ?? 0,
|
||||||
|
'image' => $json['data']['image'] ?? null,
|
||||||
|
];
|
||||||
|
return view('pages.photo-slider-edit', ['slider' => $slider]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No photo slider found or invalid API response: ', $json);
|
||||||
|
return redirect()->route('photo-slider')->with('error', 'Photo slider not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching photo slider for edit: ' . $e->getMessage());
|
||||||
|
return redirect()->route('photo-slider')->with('error', 'An error occurred while loading the photo slider.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to update a photo slider.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the request (image is optional for updates)
|
||||||
|
$request->validate([
|
||||||
|
'image' => 'nullable|file|mimes:jpeg,png,jpg,gif|max:2048',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'title' => $request->input('title'),
|
||||||
|
'description' => $request->input('description'),
|
||||||
|
'promo_type' => $request->input('type'),
|
||||||
|
'date_start' => $request->input('startDate'),
|
||||||
|
'date_end' => $request->input('endDate'),
|
||||||
|
'is_active' => $request->input('isActive', 0),
|
||||||
|
];
|
||||||
|
|
||||||
|
$client = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Attach the image if provided
|
||||||
|
if ($request->hasFile('image')) {
|
||||||
|
$client = $client->attach(
|
||||||
|
'image',
|
||||||
|
file_get_contents($request->file('image')->getRealPath()),
|
||||||
|
$request->file('image')->getClientOriginalName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->post("{$this->apiBaseUrl}/cms/updatePhotoSlider/{$uuid}", $data);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return redirect()->route('photo-slider')->with('success', 'Photo slider updated successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to update photo slider: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to update photo slider. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error updating photo slider: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while updating the photo slider: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view a photo slider.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/photoSlider/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$slider = [
|
||||||
|
'photo_slider_uuid' => $json['data']['photoslider_uuid'] ?? $json['data']['id'] ?? null,
|
||||||
|
'title' => $json['data']['title'] ?? 'Untitled',
|
||||||
|
'description' => $json['data']['description'] ?? '',
|
||||||
|
'type' => $json['data']['promo_type'] ?? 'Unknown',
|
||||||
|
'startDate' => $json['data']['date_start'] ?? null,
|
||||||
|
'endDate' => $json['data']['date_end'] ?? null,
|
||||||
|
'isActive' => $json['data']['is_active'] ?? 0,
|
||||||
|
'image' => $json['data']['image'] ?? null,
|
||||||
|
];
|
||||||
|
return view('pages.photo-slider-view', ['slider' => $slider]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No photo slider found or invalid API response: ', $json);
|
||||||
|
return redirect()->route('photo-slider')->with('error', 'Photo slider not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching photo slider for view: ' . $e->getMessage());
|
||||||
|
return redirect()->route('photo-slider')->with('error', 'An error occurred while loading the photo slider.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete a photo slider.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/cms/photoSlider/{$uuid}");
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return redirect()->route('photo-slider')->with('success', 'Photo slider deleted successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to delete photo slider: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', 'Failed to delete photo slider. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error deleting photo slider: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting the photo slider.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchDelete(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Please log in to delete photo sliders.'
|
||||||
|
], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uuids = $request->input('photoslider_uuid');
|
||||||
|
|
||||||
|
if (!is_array($uuids) || empty($uuids)) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'No photo sliders selected for deletion.'
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/cms/photoSliderBatchDelete", [
|
||||||
|
'photoslider_uuid' => $uuids,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => $response->json()['message'] ?? 'Photo sliders deleted successfully.'
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::warning('Failed to batch delete photo sliders: ', $response->json());
|
||||||
|
return response()->json([
|
||||||
|
'message' => $response->json()['message'] ?? 'Failed to delete photo sliders. Please try again.'
|
||||||
|
], $response->status());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error batch deleting photo sliders: ' . $e->getMessage());
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'An error occurred while deleting photo sliders: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class PhotoSliderViewController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->apiBaseUrl = config('services.api.base_url'); // put your base URL in config/services.php
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from photo-slider');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view photo sliders.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/photoSlider");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('Photo Slider API Response: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$sliders = array_map(function ($slider) {
|
||||||
|
return [
|
||||||
|
'id' => $slider['id'],
|
||||||
|
'title' => $slider['title'],
|
||||||
|
'type' => $slider['type'],
|
||||||
|
'startDate' => $slider['start_date'],
|
||||||
|
'endDate' => $slider['end_date'],
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
return view('pages.home page.photo-slider', [
|
||||||
|
'sliders' => $sliders,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No slider data found or invalid API response: ', $json);
|
||||||
|
return view('pages.home page.photo-slider', ['sliders' => []]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching photo slider data: ' . $e->getMessage());
|
||||||
|
return view('pages.home page.photo-slider', ['sliders' => []]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,412 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class PromotionController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api/cms';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from promotions');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view promotions.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$pageSize = 5;
|
||||||
|
$search = $request->input('_search', null);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/promotion", [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $search,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response: ', $response->json());
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$promotions = array_map(function ($promotion) {
|
||||||
|
return [
|
||||||
|
'id' => $promotion['promotion_uuid'] ?? null,
|
||||||
|
'title' => $promotion['title'] ?? '',
|
||||||
|
'type' => $promotion['type'] ?? '',
|
||||||
|
'startDate' => $promotion['date_start'] ?? '',
|
||||||
|
'endDate' => $promotion['date_end'] ?? '',
|
||||||
|
'status' => $promotion['status'] ?? '',
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($promotions);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $pageSize);
|
||||||
|
} else {
|
||||||
|
Log::warning('No promotion data found or invalid API response: ', $json);
|
||||||
|
$promotions = [];
|
||||||
|
$total = 0;
|
||||||
|
$lastPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.promotions', [
|
||||||
|
'promotions' => $promotions,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching promotions: ' . $e->getMessage());
|
||||||
|
return view('pages.promotions', [
|
||||||
|
'promotions' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a promotion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/promoTypes");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('Promo types API response: ', $json);
|
||||||
|
|
||||||
|
$promoTypes = $response->successful() && isset($json['data']) ? $json['data'] : [];
|
||||||
|
|
||||||
|
if (empty($promoTypes)) {
|
||||||
|
Log::warning('Failed to fetch promo types from API, using fallback: ', $json);
|
||||||
|
$promoTypes = ['1' => 'General', '2' => 'Loyalty Exclusive', '3' => 'User Specific'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.add-promotions', ['promoTypes' => $promoTypes]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching promo types: ' . $e->getMessage());
|
||||||
|
return view('pages.add-promotions', ['promoTypes' => ['1' => 'General', '2' => 'Loyalty Exclusive', '3' => 'User Specific']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a promotion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'title' => 'required|string|max:100',
|
||||||
|
'type' => 'required',
|
||||||
|
'promo_type' => 'required|in:1,2,3', // Based on the promo types IDs
|
||||||
|
'description' => 'required|string',
|
||||||
|
'image' => 'required|file|mimes:jpeg,png,jpg,gif|max:2048', // 2MB max
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'end_date' => 'required|date|after_or_equal:start_date',
|
||||||
|
'status' => 'required|in:On Going,Done',
|
||||||
|
'is_toppromotion' => 'nullable|in:1,0',
|
||||||
|
'is_gps' => 'nullable|in:1,0',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'title' => $request->input('title'),
|
||||||
|
'type' => $request->input('type'),
|
||||||
|
'promo_type' => $request->input('promo_type'),
|
||||||
|
'description' => $request->input('description'),
|
||||||
|
'date_start' => $request->input('start_date'),
|
||||||
|
'date_end' => $request->input('end_date'),
|
||||||
|
'status' => $request->input('status'),
|
||||||
|
'is_toppromotion' => $request->has('is_toppromotion') ? 1 : 0,
|
||||||
|
'is_gps' => $request->has('is_gps') ? 1 : 0,
|
||||||
|
'station_uuid' => $request->input('station_uuid', '[]'),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Handle the image upload
|
||||||
|
if ($request->hasFile('image')) {
|
||||||
|
$image = $request->file('image');
|
||||||
|
$payload['image'] = fopen($image->getPathname(), 'r');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Data being sent to API for creating promotion: ', $payload);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->attach('image', $payload['image'], $image->getClientOriginalName())
|
||||||
|
->post("{$this->apiBaseUrl}/promotion", array_diff_key($payload, ['image' => null]));
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('API response for creating promotion: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Promotion created successfully: ', $json);
|
||||||
|
return redirect()->route('promotions')->with('success', $json['message'] ?? 'Promotion added successfully.');
|
||||||
|
} else {
|
||||||
|
$errorMessage = $json['message'] ?? 'Failed to add promotion. Please try again.';
|
||||||
|
if (isset($json['errors'])) {
|
||||||
|
$errorMessage .= ' Errors: ' . json_encode($json['errors']);
|
||||||
|
}
|
||||||
|
throw new \Exception($errorMessage);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating promotion: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while adding the promotion: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view a promotion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/promotion/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$promotion = [
|
||||||
|
'id' => $json['data']['promotion_uuid'] ?? null,
|
||||||
|
'title' => $json['data']['title'] ?? '',
|
||||||
|
'type' => $json['data']['type'] ?? '',
|
||||||
|
'startDate' => $json['data']['date_start'] ?? '',
|
||||||
|
'endDate' => $json['data']['date_end'] ?? '',
|
||||||
|
'status' => $json['data']['status'] ?? '',
|
||||||
|
];
|
||||||
|
return view('pages.promotion-view', ['promotion' => $promotion]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No promotion found or invalid API response: ', $json);
|
||||||
|
return redirect()->back()->with('error', 'Promotion not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching promotion for view: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while loading the promotion.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to edit a promotion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/promotion/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$promotion = [
|
||||||
|
'id' => $json['data']['promotion_uuid'] ?? null,
|
||||||
|
'title' => $json['data']['title'] ?? '',
|
||||||
|
'type' => $json['data']['type'] ?? '',
|
||||||
|
'description' => $json['data']['description'] ?? '',
|
||||||
|
'image' => $json['data']['image'] ?? '',
|
||||||
|
'startDate' => $json['data']['date_start'] ?? '',
|
||||||
|
'endDate' => $json['data']['date_end'] ?? '',
|
||||||
|
'status' => $json['data']['status'] ?? '',
|
||||||
|
'is_toppromotion' => $json['data']['is_toppromotion'] ?? 0,
|
||||||
|
'is_gps' => $json['data']['is_gps'] ?? 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Determine promo_type ID based on type
|
||||||
|
$typeResponse = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/promoTypes");
|
||||||
|
|
||||||
|
$promoTypes = $typeResponse->successful() ? $typeResponse->json()['data'] ?? [] : ['1' => 'General', '2' => 'Loyalty Exclusive', '3' => 'User Specific'];
|
||||||
|
|
||||||
|
$promotion['promo_type'] = array_search($promotion['type'], $promoTypes) ?: '';
|
||||||
|
|
||||||
|
return view('pages.promotion-edit', ['promotion' => $promotion, 'promoTypes' => $promoTypes]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No promotion found or invalid API response: ', $json);
|
||||||
|
return redirect()->back()->with('error', 'Promotion not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching promotion for edit: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while loading the promotion.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function update(Request $request, $uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to update a promotion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'title' => 'required|string|max:100',
|
||||||
|
'type' => 'required',
|
||||||
|
'promo_type' => 'required|in:1,2,3',
|
||||||
|
'description' => 'required|string',
|
||||||
|
'image' => 'nullable|file|mimes:jpeg,png,jpg,gif|max:2048',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'end_date' => 'required|date|after_or_equal:start_date',
|
||||||
|
'status' => 'required|in:On Going,Done',
|
||||||
|
'is_toppromotion' => 'nullable|in:1,0',
|
||||||
|
'is_gps' => 'nullable|in:1,0',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'title' => $request->input('title'),
|
||||||
|
'type' => $request->input('type'),
|
||||||
|
'promo_type' => $request->input('promo_type'),
|
||||||
|
'description' => $request->input('description'),
|
||||||
|
'date_start' => $request->input('start_date'),
|
||||||
|
'date_end' => $request->input('end_date'),
|
||||||
|
'status' => $request->input('status'),
|
||||||
|
'is_toppromotion' => $request->has('is_toppromotion') ? 1 : 0,
|
||||||
|
'is_gps' => $request->has('is_gps') ? 1 : 0,
|
||||||
|
'station_uuid' => $request->input('station_uuid', '[]'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$client = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->hasFile('image')) {
|
||||||
|
$image = $request->file('image');
|
||||||
|
$payload['image'] = fopen($image->getPathname(), 'r');
|
||||||
|
$response = $client->attach('image', $payload['image'], $image->getClientOriginalName())
|
||||||
|
->post("{$this->apiBaseUrl}/updatePromotion/{$uuid}", array_diff_key($payload, ['image' => null]));
|
||||||
|
} else {
|
||||||
|
$response = $client->post("{$this->apiBaseUrl}/updatePromotion/{$uuid}", $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('API response for updating promotion: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Promotion updated successfully: ', $json);
|
||||||
|
return redirect()->route('promotions')->with('success', $json['message'] ?? 'Promotion updated successfully.');
|
||||||
|
} else {
|
||||||
|
$errorMessage = $json['message'] ?? 'Failed to update promotion. Please try again.';
|
||||||
|
if (isset($json['errors'])) {
|
||||||
|
$errorMessage .= ' Errors: ' . json_encode($json['errors']);
|
||||||
|
}
|
||||||
|
return redirect()->back()->with('error', $errorMessage);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error updating promotion: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while updating the promotion: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function destroy($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete a promotion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/promotion/{$uuid}");
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Promotion deleted successfully: ' . $uuid);
|
||||||
|
return redirect()->route('promotions')->with('success', 'Promotion deleted successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to delete promotion: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to delete promotion. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error deleting promotion: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting the promotion.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchDelete(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Please log in to delete promotions.'
|
||||||
|
], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uuids = $request->input('promotion_uuid', []);
|
||||||
|
|
||||||
|
if (!is_array($uuids) || empty($uuids)) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'No promotions selected for deletion.'
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/promotionBatchDelete", [
|
||||||
|
'promotion_uuid' => $uuids,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Promotions batch deleted successfully: ', $uuids);
|
||||||
|
return response()->json([
|
||||||
|
'message' => $response->json()['message'] ?? 'Selected promotions deleted successfully.'
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::warning('Failed to batch delete promotions: ', $response->json());
|
||||||
|
return response()->json([
|
||||||
|
'message' => $response->json()['message'] ?? 'Failed to delete promotions. Please try again.'
|
||||||
|
], $response->status());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error batch deleting promotions: ' . $e->getMessage());
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'An error occurred while deleting the promotions: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,375 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class ReportsController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->apiBaseUrl = env('EXTERNAL_API_URL', 'http://localhost:8081/api/');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function makeApiRequest($endpoint, $params, $isDownload = false)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info("No access token found, redirecting to login from {$endpoint}");
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view reports.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$baseUrl = rtrim($this->apiBaseUrl, '/');
|
||||||
|
$endpoint = ltrim($endpoint, '/');
|
||||||
|
$fullUrl = "{$baseUrl}/{$endpoint}";
|
||||||
|
|
||||||
|
Log::info("Making API request to: {$fullUrl}", ['params' => $params]);
|
||||||
|
$client = Http::withHeaders([
|
||||||
|
'Accept' => $isDownload ? 'text/csv' : 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->timeout(30);
|
||||||
|
|
||||||
|
$response = $client->get($fullUrl, $params);
|
||||||
|
|
||||||
|
Log::info("API response status: {$response->status()}", [
|
||||||
|
'endpoint' => $endpoint,
|
||||||
|
'headers' => $response->headers()
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning("Unauthorized or Forbidden API response for {$endpoint}", ['response' => $response->body()]);
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response->successful()) {
|
||||||
|
Log::error("API request failed for {$endpoint}", [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'response' => $response->body(),
|
||||||
|
'headers' => $response->headers()
|
||||||
|
]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isDownload) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->json();
|
||||||
|
} catch (\Illuminate\Http\Client\ConnectionException $e) {
|
||||||
|
Log::error("Connection error during API request to {$endpoint}", [
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
'params' => $params
|
||||||
|
]);
|
||||||
|
return null;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error("Unexpected error during API request to {$endpoint}", [
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
'params' => $params
|
||||||
|
]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mobileUsage(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'page' => $request->input('page', 1),
|
||||||
|
'page_size' => 5,
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'sorting' => $request->input('sort', 'date|desc'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->makeApiRequest('cms/reportMobileUsage', $params);
|
||||||
|
|
||||||
|
if (is_a($data, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mobileUsageData = [];
|
||||||
|
$currentPage = $params['page'];
|
||||||
|
$lastPage = 1;
|
||||||
|
$total = 0;
|
||||||
|
$errorMessage = null;
|
||||||
|
|
||||||
|
if ($data && isset($data['data'])) {
|
||||||
|
$mobileUsageData = array_map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item['id'] ?? uniqid(),
|
||||||
|
'date' => $item['date'],
|
||||||
|
'activeUsers' => $item['active_users'],
|
||||||
|
'inactiveUsers' => $item['inactive_users'],
|
||||||
|
'lockedUsers' => $item['locked_users'],
|
||||||
|
];
|
||||||
|
}, $data['data']);
|
||||||
|
$currentPage = $data['meta']['current_page'] ?? 1;
|
||||||
|
$lastPage = $data['meta']['last_page'] ?? 1;
|
||||||
|
$total = $data['meta']['total'] ?? count($mobileUsageData);
|
||||||
|
} elseif ($data && isset($data['message'])) {
|
||||||
|
Log::info("API returned message for mobileUsage", ['message' => $data['message']]);
|
||||||
|
$errorMessage = $data['message'];
|
||||||
|
} else {
|
||||||
|
Log::warning("No data returned or invalid response structure for mobileUsage", ['data' => $data]);
|
||||||
|
$errorMessage = 'Failed to fetch mobile usage data.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.reports.mobile-usage-report', compact('mobileUsageData', 'currentPage', 'lastPage', 'total', 'errorMessage'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exportMobileUsage(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
'sorting' => $request->input('sort', 'date|desc'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->makeApiRequest('cms/reportMobileUsageExport', $params, true);
|
||||||
|
|
||||||
|
if (is_a($response, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response) {
|
||||||
|
Log::warning("Failed to export mobile usage data", ['params' => $params]);
|
||||||
|
return redirect()->back()->with('error', 'Failed to export CSV.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = "reports_mobile_usage" . date("mdY") . ".csv";
|
||||||
|
|
||||||
|
return response($response->body(), 200)
|
||||||
|
->header('Content-Type', 'text/csv')
|
||||||
|
->header('Content-Disposition', "attachment; filename=\"$filename\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registration(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'page' => $request->input('page', 1),
|
||||||
|
'page_size' => 5,
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'sorting' => $request->input('sort', 'date|desc'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->makeApiRequest('cms/reportRegistration', $params);
|
||||||
|
|
||||||
|
if (is_a($data, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$registrationData = [];
|
||||||
|
$currentPage = $params['page'];
|
||||||
|
$lastPage = 1;
|
||||||
|
$total = 0;
|
||||||
|
$errorMessage = null;
|
||||||
|
|
||||||
|
if ($data && isset($data['data'])) {
|
||||||
|
$registrationData = array_map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item['id'] ?? uniqid(),
|
||||||
|
'date' => $item['date'],
|
||||||
|
'activatedCards' => $item['activated_cards'],
|
||||||
|
'registeredMembers' => $item['registered_members'],
|
||||||
|
];
|
||||||
|
}, $data['data']);
|
||||||
|
$currentPage = $data['meta']['current_page'] ?? 1;
|
||||||
|
$lastPage = $data['meta']['last_page'] ?? 1;
|
||||||
|
$total = $data['meta']['total'] ?? count($registrationData);
|
||||||
|
} elseif ($data && isset($data['message'])) {
|
||||||
|
Log::info("API returned message for registration", ['message' => $data['message']]);
|
||||||
|
$errorMessage = $data['message'];
|
||||||
|
} else {
|
||||||
|
Log::warning("No data returned or invalid response structure for registration", ['data' => $data]);
|
||||||
|
$errorMessage = 'Failed to fetch registration data.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.reports.registration-report', compact('registrationData', 'currentPage', 'lastPage', 'total', 'errorMessage'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exportRegistration(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
'sorting' => $request->input('sort', 'date|desc'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->makeApiRequest('cms/reportRegistrationExport', $params, true);
|
||||||
|
|
||||||
|
if (is_a($response, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response) {
|
||||||
|
Log::warning("Failed to export registration data", ['params' => $params]);
|
||||||
|
return redirect()->back()->with('error', 'Failed to export CSV.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = "registration" . date("mdY") . ".csv";
|
||||||
|
|
||||||
|
return response($response->body(), 200)
|
||||||
|
->header('Content-Type', 'text/csv')
|
||||||
|
->header('Content-Disposition', "attachment; filename=\"$filename\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stationRating(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'page' => $request->input('page', 1),
|
||||||
|
'page_size' => 5,
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'sorting' => $request->input('sort', 'date|desc'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->makeApiRequest('cms/reportStationRatings', $params);
|
||||||
|
|
||||||
|
if (is_a($data, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stationRatingData = [];
|
||||||
|
$currentPage = $params['page'];
|
||||||
|
$lastPage = 1;
|
||||||
|
$total = 0;
|
||||||
|
$errorMessage = null;
|
||||||
|
|
||||||
|
if ($data && isset($data['data'])) {
|
||||||
|
$stationRatingData = array_map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item['id'] ?? uniqid(),
|
||||||
|
'transactionDateTime' => $item['date'],
|
||||||
|
'cardNumber' => $item['card_number'],
|
||||||
|
'salesInvoice' => $item['invoice'],
|
||||||
|
'station' => $item['station'],
|
||||||
|
'ratings' => $item['rate'],
|
||||||
|
];
|
||||||
|
}, $data['data']);
|
||||||
|
$currentPage = $data['meta']['current_page'] ?? 1;
|
||||||
|
$lastPage = $data['meta']['last_page'] ?? 1;
|
||||||
|
$total = $data['meta']['total'] ?? count($stationRatingData);
|
||||||
|
} elseif ($data && isset($data['message'])) {
|
||||||
|
Log::info("API returned message for stationRating", ['message' => $data['message']]);
|
||||||
|
$errorMessage = $data['message'];
|
||||||
|
} else {
|
||||||
|
Log::warning("No data returned or invalid response structure for stationRating", ['data' => $data]);
|
||||||
|
$errorMessage = 'Failed to fetch station rating data.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.reports.station-rating-report', compact('stationRatingData', 'currentPage', 'lastPage', 'total', 'errorMessage'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exportStationRating(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
'sorting' => $request->input('sort', 'date|desc'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->makeApiRequest('cms/reportStationRatingsExport', $params, true);
|
||||||
|
|
||||||
|
if (is_a($response, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response) {
|
||||||
|
Log::warning("Failed to export station rating data", ['params' => $params]);
|
||||||
|
return redirect()->back()->with('error', 'Failed to export CSV.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = "reports_station_rating" . date("mdY") . ".csv";
|
||||||
|
|
||||||
|
return response($response->body(), 200)
|
||||||
|
->header('Content-Type', 'text/csv')
|
||||||
|
->header('Content-Disposition', "attachment; filename=\"$filename\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function topUp(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'page' => $request->input('page', 1),
|
||||||
|
'page_size' => 5,
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'sorting' => $request->input('sort', 'transaction_date_time|desc'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->makeApiRequest('cms/reportTopUp', $params);
|
||||||
|
|
||||||
|
if (is_a($data, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$topUpData = [];
|
||||||
|
$currentPage = $params['page'];
|
||||||
|
$lastPage = 1;
|
||||||
|
$total = 0;
|
||||||
|
$errorMessage = null;
|
||||||
|
|
||||||
|
if ($data && isset($data['data'])) {
|
||||||
|
$topUpData = array_map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item['id'] ?? uniqid(),
|
||||||
|
'transactionDateTime' => $item['transaction_date_time'],
|
||||||
|
'cardNumber' => $item['card_number'],
|
||||||
|
'topUpAmount' => $item['top_up_amount'],
|
||||||
|
];
|
||||||
|
}, $data['data']);
|
||||||
|
$currentPage = $data['meta']['current_page'] ?? 1;
|
||||||
|
$lastPage = $data['meta']['last_page'] ?? 1;
|
||||||
|
$total = $data['meta']['total'] ?? count($topUpData);
|
||||||
|
} elseif ($data && isset($data['message'])) {
|
||||||
|
Log::info("API returned message for topUp", ['message' => $data['message']]);
|
||||||
|
$errorMessage = $data['message'];
|
||||||
|
} else {
|
||||||
|
Log::warning("No data returned or invalid response structure for topUp", ['data' => $data]);
|
||||||
|
$errorMessage = 'Failed to fetch top-up data.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.reports.top-up-usage-report', compact('topUpData', 'currentPage', 'lastPage', 'total', 'errorMessage'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exportTopUp(Request $request)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'date_start' => $request->input('date_start'),
|
||||||
|
'date_end' => $request->input('date_end'),
|
||||||
|
'_search' => $request->input('_search'),
|
||||||
|
'sorting' => $request->input('sort', 'transaction_date_time|desc'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->makeApiRequest('cms/reportTopUpExport', $params, true);
|
||||||
|
|
||||||
|
if (is_a($response, '\Illuminate\Http\RedirectResponse')) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$response) {
|
||||||
|
Log::warning("Failed to export top-up data", ['params' => $params]);
|
||||||
|
return redirect()->back()->with('error', 'Failed to export CSV.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = "reports_top_up" . date("mdY") . ".csv";
|
||||||
|
|
||||||
|
return response($response->body(), 200)
|
||||||
|
->header('Content-Type', 'text/csv')
|
||||||
|
->header('Content-Disposition', "attachment; filename=\"$filename\"");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,144 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class StationController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api/cms';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from stations');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view stations.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$pageSize = 5;
|
||||||
|
$search = $request->input('_search', null);
|
||||||
|
$sort = $request->input('sort', 'station_code|asc');
|
||||||
|
|
||||||
|
Log::info('Initiating API request to fetch stations', [
|
||||||
|
'url' => "{$this->apiBaseUrl}/getStations",
|
||||||
|
'params' => [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $search,
|
||||||
|
'sort' => $sort,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->timeout(30)->get("{$this->apiBaseUrl}/getStations", [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $search,
|
||||||
|
'sort' => $sort,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
$rawResponse = $response->body();
|
||||||
|
|
||||||
|
Log::info('API response received for stations', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'headers' => $response->headers(),
|
||||||
|
'data' => $json,
|
||||||
|
'raw_response' => $rawResponse,
|
||||||
|
'reason' => $response->reason(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response for stations', ['response' => $json]);
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['code']) && $json['code'] == 200 && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$stations = array_map(function ($station) {
|
||||||
|
return [
|
||||||
|
'id' => $station['station_uuid'] ?? '',
|
||||||
|
'station_code' => $station['code'] ?? '',
|
||||||
|
'station_name' => $station['description'] ?? '',
|
||||||
|
'branch_name' => $station['branch_name'] ?? '',
|
||||||
|
'date_created' => $station['date_created'] ?? '',
|
||||||
|
'created_by' => $station['created_by'] ?? '',
|
||||||
|
'modified_by' => $station['modified_by'] ?? '',
|
||||||
|
'date_modified' => $station['date_modified'] ?? '',
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
// Use meta for pagination if provided, else calculate locally
|
||||||
|
$total = $json['meta']['total'] ?? count($stations);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $pageSize);
|
||||||
|
|
||||||
|
// Apply search filter locally if needed
|
||||||
|
if ($search) {
|
||||||
|
$searchTerm = strtolower($search);
|
||||||
|
$stations = array_filter($stations, function ($station) use ($searchTerm) {
|
||||||
|
return str_contains(strtolower($station['station_code'] ?? ''), $searchTerm) ||
|
||||||
|
str_contains(strtolower($station['station_name'] ?? ''), $searchTerm);
|
||||||
|
});
|
||||||
|
$stations = array_values($stations);
|
||||||
|
$total = count($stations);
|
||||||
|
$lastPage = ceil($total / $pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply sorting locally
|
||||||
|
if ($sort) {
|
||||||
|
[$sortField, $sortDir] = explode('|', $sort);
|
||||||
|
usort($stations, function ($a, $b) use ($sortField, $sortDir) {
|
||||||
|
$aValue = $a[$sortField] ?? '';
|
||||||
|
$bValue = $b[$sortField] ?? '';
|
||||||
|
return $sortDir === 'asc' ? strcmp($aValue, $bValue) : strcmp($bValue, $aValue);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paginate locally
|
||||||
|
$start = ($page - 1) * $pageSize;
|
||||||
|
$stations = array_slice($stations, $start, $pageSize);
|
||||||
|
} else {
|
||||||
|
Log::warning('No station data found or invalid API response', ['response' => $json]);
|
||||||
|
$stations = [];
|
||||||
|
$total = 0;
|
||||||
|
$lastPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Processed stations data', [
|
||||||
|
'stations_count' => count($stations),
|
||||||
|
'total' => $total,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'stations' => $stations,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('pages.station locator.stations', [
|
||||||
|
'stations' => $stations,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching stations: ' . $e->getMessage(), [
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
return view('pages.station locator.stations', [
|
||||||
|
'stations' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
'search' => $search,
|
||||||
|
])->with('error', 'Failed to fetch stations: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,346 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class TermsAndPrivacyController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api/cms';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from terms-and-privacy');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view terms and privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$pageSize = 5;
|
||||||
|
$search = $request->input('_search', null);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/TermsAndPrivacy", [
|
||||||
|
'page' => $page,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'_search' => $search,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response: ', $response->json());
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$termsAndPrivacy = array_map(function ($item) {
|
||||||
|
return [
|
||||||
|
'id' => $item['tp_uuid'] ?? null,
|
||||||
|
'title' => $item['title'] ?? '',
|
||||||
|
'details' => $item['details'] ?? '',
|
||||||
|
'type' => $item['type'] == 1 ? 'Terms' : ($item['type'] == 2 ? 'Privacy' : 'Unknown'),
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($termsAndPrivacy);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $pageSize);
|
||||||
|
} else {
|
||||||
|
Log::warning('No terms and privacy data found or invalid API response: ', $json);
|
||||||
|
$termsAndPrivacy = [];
|
||||||
|
$total = 0;
|
||||||
|
$lastPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.about us.terms-and-privacy', [
|
||||||
|
'termsAndPrivacy' => $termsAndPrivacy,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching terms and privacy: ' . $e->getMessage());
|
||||||
|
return view('pages.about us.terms-and-privacy', [
|
||||||
|
'termsAndPrivacy' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add terms or privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('pages.terms-and-privacy.create', ['types' => ['1' => 'Terms', '2' => 'Privacy']]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error loading create terms and privacy page: ' . $e->getMessage());
|
||||||
|
return view('pages.terms-and-privacy.create', ['types' => ['1' => 'Terms', '2' => 'Privacy']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add terms or privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'details' => 'required|string',
|
||||||
|
'type' => 'required|in:1,2',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'title' => $request->input('title'),
|
||||||
|
'details' => $request->input('details'),
|
||||||
|
'type' => (int) $request->input('type'),
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::info('Data being sent to API for creating terms or privacy: ', $payload);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/TermsAndPrivacy", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('API response for creating terms or privacy: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Terms or privacy created successfully: ', $json);
|
||||||
|
return redirect()->route('terms-and-privacy')->with('success', $json['message'] ?? 'Terms or privacy added successfully.');
|
||||||
|
} else {
|
||||||
|
$errorMessage = $json['message'] ?? 'Failed to add terms or privacy. Please try again.';
|
||||||
|
if (isset($json['errors'])) {
|
||||||
|
$errorMessage .= ' Errors: ' . json_encode($json['errors']);
|
||||||
|
}
|
||||||
|
throw new \Exception($errorMessage);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating terms or privacy: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while adding the terms or privacy: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view terms or privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/TermsAndPrivacy/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$item = [
|
||||||
|
'id' => $json['data']['tp_uuid'] ?? null,
|
||||||
|
'title' => $json['data']['title'] ?? '',
|
||||||
|
'details' => $json['data']['details'] ?? '',
|
||||||
|
'type' => $json['data']['type'] == 1 ? 'Terms' : ($json['data']['type'] == 2 ? 'Privacy' : 'Unknown'),
|
||||||
|
];
|
||||||
|
return view('pages.terms-and-privacy.show', ['item' => $item]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No terms or privacy found or invalid API response: ', $json);
|
||||||
|
return redirect()->back()->with('error', 'Terms or privacy not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching terms or privacy for view: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while loading the terms or privacy.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to edit terms or privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/TermsAndPrivacy/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$item = [
|
||||||
|
'id' => $json['data']['tp_uuid'] ?? null,
|
||||||
|
'title' => $json['data']['title'] ?? '',
|
||||||
|
'details' => $json['data']['details'] ?? '',
|
||||||
|
'type' => $json['data']['type'] ?? '',
|
||||||
|
];
|
||||||
|
return view('pages.terms-and-privacy.edit', ['item' => $item, 'types' => ['1' => 'Terms', '2' => 'Privacy']]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No terms and privacy found or invalid API response: ', $json);
|
||||||
|
return redirect()->back()->with('error', 'Terms or privacy not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching terms or privacy for edit: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while loading the terms or privacy.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to update terms or privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'details' => 'required|string',
|
||||||
|
'type' => 'required|in:1,2',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'title' => $request->input('title'),
|
||||||
|
'details' => $request->input('details'),
|
||||||
|
'type' => (int) $request->input('type'),
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::info('Data being sent to API for updating terms or privacy: ', $payload);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->put("{$this->apiBaseUrl}/TermsAndPrivacy/{$uuid}", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
Log::info('API response for updating terms or privacy: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Terms or privacy updated successfully: ', $json);
|
||||||
|
return redirect()->route('terms-and-privacy')->with('success', $json['message'] ?? 'Terms or privacy updated successfully.');
|
||||||
|
} else {
|
||||||
|
$errorMessage = $json['message'] ?? 'Failed to update terms or privacy. Please try again.';
|
||||||
|
if (isset($json['errors'])) {
|
||||||
|
$errorMessage .= ' Errors: ' . json_encode($json['errors']);
|
||||||
|
}
|
||||||
|
return redirect()->back()->with('error', $errorMessage);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error updating terms or privacy: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while updating the terms or privacy: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete terms or privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/TermsAndPrivacy/{$uuid}");
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Terms or privacy deleted successfully: ' . $uuid);
|
||||||
|
return redirect()->route('terms-and-privacy')->with('success', 'Terms or privacy deleted successfully.');
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to delete terms or privacy: ', $response->json());
|
||||||
|
return redirect()->back()->with('error', $response->json()['message'] ?? 'Failed to delete terms or privacy. Please try again.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error deleting terms or privacy: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting the terms or privacy.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchDelete(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from terms-and-privacy batch delete');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete terms or privacy.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$uuids = $request->input('tp_uuid', []);
|
||||||
|
if (is_string($uuids)) {
|
||||||
|
$uuids = json_decode($uuids, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
Log::warning('Invalid JSON format for tp_uuid', ['input' => $uuids]);
|
||||||
|
return redirect()->back()->with('error', 'Invalid terms or privacy UUID format.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($uuids) || !is_array($uuids)) {
|
||||||
|
Log::warning('No valid tp_uuids provided for batch delete', ['uuids' => $uuids]);
|
||||||
|
return redirect()->back()->with('error', 'No terms or privacy selected for deletion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Attempting batch delete for UUIDs: ', ['uuids' => $uuids]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
])->delete("{$this->apiBaseUrl}/TermsAndPrivacyBatchDelete", [
|
||||||
|
'tp_uuid' => $uuids,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
Log::info('Batch delete response: ', ['response' => $json, 'status' => $response->status(), 'headers' => $response->headers()]);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['status']) && $json['status'] === 'success') {
|
||||||
|
Log::info('Batch delete successful for UUIDs: ', ['uuids' => $uuids, 'response' => $json]);
|
||||||
|
return redirect()->route('terms-and-privacy')
|
||||||
|
->with('success', $json['message'] ?? 'Selected terms or privacy deleted successfully.');
|
||||||
|
} else {
|
||||||
|
Log::error('Batch delete failed: ', ['response' => $json, 'status' => $response->status(), 'headers' => $response->headers()]);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to delete terms or privacy. Status: ' . $response->status());
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error in batch delete: ', ['error' => $e->getMessage(), 'uuids' => $uuids ?? [], 'trace' => $e->getTraceAsString()]);
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting terms or privacy: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,368 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class TopUpController extends Controller
|
||||||
|
{
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from top-up');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view top-ups.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = $request->input('page', 1);
|
||||||
|
$perPage = 5;
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/topUp", [
|
||||||
|
'page' => $page,
|
||||||
|
'per_page' => $perPage,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->status() === 401 || $response->status() === 403) {
|
||||||
|
Log::warning('Unauthorized or Forbidden API response: ', $response->json());
|
||||||
|
return redirect()->route('login')->with('error', 'Your session has expired. Please log in again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
Log::info("TopUp API Response (Page {$page}): ", $json);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$topups = array_map(function ($topup) {
|
||||||
|
Log::info('Processing top-up record: ', $topup);
|
||||||
|
return [
|
||||||
|
'topup_uuid' => $topup['topup_uuid'] ?? $topup['id'] ?? null,
|
||||||
|
'freeCode' => $topup['fee_code'] ?? 'N/A',
|
||||||
|
'name' => $topup['name'] ?? 'Unnamed',
|
||||||
|
'value' => $topup['amount'] ?? 0,
|
||||||
|
'type' => $topup['type'] ?? 'Unknown',
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
$total = $json['meta']['total'] ?? count($topups);
|
||||||
|
$lastPage = $json['meta']['last_page'] ?? ceil($total / $perPage);
|
||||||
|
|
||||||
|
return view('pages.top-up', [
|
||||||
|
'topups' => $topups,
|
||||||
|
'currentPage' => $page,
|
||||||
|
'lastPage' => $lastPage,
|
||||||
|
'total' => $total,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No top-up data found or invalid API response: ', $json);
|
||||||
|
return view('pages.top-up', [
|
||||||
|
'topups' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching top-up data: ' . $e->getMessage());
|
||||||
|
return view('pages.top-up', [
|
||||||
|
'topups' => [],
|
||||||
|
'currentPage' => 1,
|
||||||
|
'lastPage' => 1,
|
||||||
|
'total' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from top-up create');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a top-up.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/generateFeeCode");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']['fee_code'])) {
|
||||||
|
$freeCode = $json['data']['fee_code'];
|
||||||
|
return view('pages.add-top-up', ['freeCode' => $freeCode]);
|
||||||
|
} else {
|
||||||
|
Log::warning('Failed to generate fee code: ', $json);
|
||||||
|
return view('pages.add-top-up', ['freeCode' => '']);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error generating fee code: ' . $e->getMessage());
|
||||||
|
return view('pages.add-top-up', ['freeCode' => '']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a top-up.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'freeCode' => 'required|string|max:255',
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'value' => 'required|numeric|min:0',
|
||||||
|
'type' => 'required|in:1,2,3',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'fee_code' => $validated['freeCode'],
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'amount' => $validated['value'],
|
||||||
|
'type' => $validated['type'],
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::info('API Payload for creating top-up: ', $payload);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/topUp", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Top-up created successfully: ', $json);
|
||||||
|
return redirect()->route('top-up')
|
||||||
|
->with('success', $json['message'] ?? 'Top-up added successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to create top-up: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to add top-up.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating top-up: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while adding the top-up.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from top-up show');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view top-up details.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/topUp/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$topup = [
|
||||||
|
'topup_uuid' => $json['data']['topup_uuid'],
|
||||||
|
'freeCode' => $json['data']['fee_code'],
|
||||||
|
'name' => $json['data']['name'],
|
||||||
|
'value' => $json['data']['amount'],
|
||||||
|
'type' => $json['data']['type'],
|
||||||
|
];
|
||||||
|
return view('pages.view-top-up', ['topup' => $topup]);
|
||||||
|
} else {
|
||||||
|
Log::warning('Top-up not found: ', $json);
|
||||||
|
return redirect()->route('top-up')->with('error', $json['message'] ?? 'Top-up not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching top-up: ' . $e->getMessage());
|
||||||
|
return redirect()->route('top-up')->with('error', 'An error occurred while fetching the top-up.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from top-up edit');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to edit a top-up.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/topUp/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$topup = [
|
||||||
|
'topup_uuid' => $json['data']['topup_uuid'],
|
||||||
|
'freeCode' => $json['data']['fee_code'],
|
||||||
|
'name' => $json['data']['name'],
|
||||||
|
'value' => $json['data']['amount'],
|
||||||
|
'type' => $json['data']['type'],
|
||||||
|
];
|
||||||
|
return view('pages.edit-top-up', ['topup' => $topup]);
|
||||||
|
} else {
|
||||||
|
Log::warning('Top-up not found: ', $json);
|
||||||
|
return redirect()->route('top-up')->with('error', $json['message'] ?? 'Top-up not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching top-up for edit: ' . $e->getMessage());
|
||||||
|
return redirect()->route('top-up')->with('error', 'An error occurred while fetching the top-up.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to update a top-up.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'freeCode' => 'required|string|max:255',
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'value' => 'required|numeric|min:0',
|
||||||
|
'type' => 'required|in:Prepaid,Postpaid,Bonus',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'fee_code' => $validated['freeCode'],
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'amount' => $validated['value'],
|
||||||
|
'type' => $validated['type'],
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::info('API Payload for updating top-up: ', $payload);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->put("{$this->apiBaseUrl}/cms/topUp/{$uuid}", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Top-up updated successfully: ', $json);
|
||||||
|
return redirect()->route('top-up')
|
||||||
|
->with('success', $json['message'] ?? 'Top-up updated successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to update top-up: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to update top-up.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error updating top-up: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while updating the top-up.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete a top-up.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/cms/topUp/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Top-up deleted successfully: ', $json);
|
||||||
|
return redirect()->route('top-up')
|
||||||
|
->with('success', $json['message'] ?? 'Top-up deleted successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to delete top-up: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to delete top-up.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error deleting top-up: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting the top-up.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchDelete(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from batch delete');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete top-ups.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$uuids = $request->input('topup_uuid', []);
|
||||||
|
if (is_string($uuids)) {
|
||||||
|
$uuids = json_decode($uuids, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
Log::warning('Invalid JSON format for topup_uuid', ['input' => $uuids]);
|
||||||
|
return redirect()->back()->with('error', 'Invalid top-up UUID format.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($uuids) || !is_array($uuids)) {
|
||||||
|
Log::warning('No valid topup_uuids provided for batch delete', ['uuids' => $uuids]);
|
||||||
|
return redirect()->back()->with('error', 'No top-ups selected for deletion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Attempting batch delete for UUIDs: ', ['uuids' => $uuids]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
])->delete("{$this->apiBaseUrl}/cms/topUpBatchDelete", [
|
||||||
|
'topup_uuid' => $uuids,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
Log::info('Batch delete response: ', ['response' => $json, 'status' => $response->status(), 'headers' => $response->headers()]);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['status']) && $json['status'] === 'success') {
|
||||||
|
Log::info('Batch delete successful for UUIDs: ', ['uuids' => $uuids, 'response' => $json]);
|
||||||
|
return redirect()->route('top-up')
|
||||||
|
->with('success', $json['message'] ?? 'Top-ups deleted successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Batch delete failed: ', ['response' => $json, 'status' => $response->status(), 'headers' => $response->headers()]);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to delete top-ups. Status: ' . $response->status());
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error in batch delete: ', ['error' => $e->getMessage(), 'uuids' => $uuids ?? [], 'trace' => $e->getTraceAsString()]);
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting top-ups: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,384 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class UserManagementController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $apiBaseUrl = 'http://192.168.100.6:8081/api';
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from user-management');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view user management.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/admin");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
Log::info('User Management API Response: ', $json);
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data']) && is_array($json['data'])) {
|
||||||
|
$users = array_map(function ($admin) {
|
||||||
|
return [
|
||||||
|
'admin_uuid' => $admin['admin_uuid'],
|
||||||
|
'username' => $admin['username'],
|
||||||
|
'firstName' => $admin['firstname'],
|
||||||
|
'lastName' => $admin['lastname'],
|
||||||
|
'role' => $admin['role'] == '1' ? 'User' : 'Admin',
|
||||||
|
'email' => $admin['email'],
|
||||||
|
'status' => $admin['status'] ? 'Active' : 'Inactive',
|
||||||
|
];
|
||||||
|
}, $json['data']);
|
||||||
|
|
||||||
|
return view('pages.user-management', [
|
||||||
|
'users' => $users,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
Log::warning('No user data found or invalid API response: ', $json);
|
||||||
|
return view('pages.user-management', [
|
||||||
|
'users' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching user data: ' . $e->getMessage());
|
||||||
|
return view('pages.user-management', [
|
||||||
|
'users' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('pages.user-management.add-user');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to add a user.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'username' => 'required|string|max:255',
|
||||||
|
'firstName' => 'required|string|max:255',
|
||||||
|
'lastName' => 'required|string|max:255',
|
||||||
|
'role' => 'required|in:0,1',
|
||||||
|
'email' => 'required|email|max:255',
|
||||||
|
'status' => 'required|in:active,inactive',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Generate password via API
|
||||||
|
$passwordResponse = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/generatePassword");
|
||||||
|
|
||||||
|
$passwordJson = $passwordResponse->json();
|
||||||
|
|
||||||
|
if (!$passwordResponse->successful() || !isset($passwordJson['data']['password'])) {
|
||||||
|
Log::error('Failed to generate password: ', $passwordJson);
|
||||||
|
return redirect()->back()->with('error', 'Failed to generate password.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$generatedPassword = $passwordJson['data']['password'];
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'username' => $validated['username'],
|
||||||
|
'firstname' => $validated['firstName'],
|
||||||
|
'lastname' => $validated['lastName'],
|
||||||
|
'role' => $validated['role'],
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'password' => $generatedPassword,
|
||||||
|
'status' => $validated['status'],
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::info('API Payload for creating user: ', $payload);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/admin", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('User created successfully: ', $json);
|
||||||
|
return redirect()->route('user.management')
|
||||||
|
->with('success', "User added successfully. Generated password: {$generatedPassword}");
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to create user: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to add user.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating user: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while adding the user.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from user-management show');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to view user details.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/admin/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$userData = [
|
||||||
|
'admin_uuid' => $json['data']['admin_uuid'],
|
||||||
|
'username' => $json['data']['username'],
|
||||||
|
'firstName' => $json['data']['firstname'],
|
||||||
|
'lastName' => $json['data']['lastname'],
|
||||||
|
'role' => $json['data']['role'] == '1' ? 'Admin' : 'User',
|
||||||
|
'email' => $json['data']['email'],
|
||||||
|
'status' => $json['data']['status'] ? 'Active' : 'Inactive',
|
||||||
|
'generated_password' => $json['data']['generated_password'] ?? null,
|
||||||
|
];
|
||||||
|
return view('pages.user-management.show-user', ['user' => $userData]);
|
||||||
|
} else {
|
||||||
|
Log::warning('User not found: ', $json);
|
||||||
|
return redirect()->route('user.management')->with('error', $json['message'] ?? 'User not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching user: ' . $e->getMessage());
|
||||||
|
return redirect()->route('user.management')->with('error', 'An error occurred while fetching the user.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
Log::info('No access token found, redirecting to login from user-management edit');
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to edit a user.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->get("{$this->apiBaseUrl}/cms/admin/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful() && isset($json['data'])) {
|
||||||
|
$userData = [
|
||||||
|
'admin_uuid' => $json['data']['admin_uuid'],
|
||||||
|
'username' => $json['data']['username'],
|
||||||
|
'firstName' => $json['data']['firstname'],
|
||||||
|
'lastName' => $json['data']['lastname'],
|
||||||
|
'role' => $json['data']['role'] == '1' ? 'Admin' : 'User',
|
||||||
|
'email' => $json['data']['email'],
|
||||||
|
'status' => $json['data']['status'] ? 'Active' : 'Inactive',
|
||||||
|
];
|
||||||
|
return view('pages.user-management.edit-user', ['user' => $userData]);
|
||||||
|
} else {
|
||||||
|
Log::warning('User not found: ', $json);
|
||||||
|
return redirect()->route('user.management')->with('error', $json['message'] ?? 'User not found.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error fetching user for edit: ' . $e->getMessage());
|
||||||
|
return redirect()->route('user.management')->with('error', 'An error occurred while fetching the user.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to update a user.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'username' => 'required|string|max:255',
|
||||||
|
'firstName' => 'required|string|max:255',
|
||||||
|
'lastName' => 'required|string|max:255',
|
||||||
|
'role' => 'required|in:0,1',
|
||||||
|
'email' => 'required|email|max:255',
|
||||||
|
'password' => 'nullable|string|min:8',
|
||||||
|
'status' => 'required|in:active,inactive',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'username' => $validated['username'],
|
||||||
|
'firstname' => $validated['firstName'],
|
||||||
|
'lastname' => $validated['lastName'],
|
||||||
|
'role' => $validated['role'],
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'status' => $validated['status'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($validated['password'])) {
|
||||||
|
$data['password'] = $validated['password'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('API Payload for updating user: ', $data);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->put("{$this->apiBaseUrl}/cms/admin/{$uuid}", $data);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('User updated successfully: ', $json);
|
||||||
|
return redirect()->route('user.management')
|
||||||
|
->with('success', $json['message'] ?? 'User updated successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to update user: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to update user.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error updating user: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while updating the user.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete a user.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->delete("{$this->apiBaseUrl}/cms/admin/{$uuid}");
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('User deleted successfully: ', $json);
|
||||||
|
return redirect()->route('user.management')
|
||||||
|
->with('success', $json['message'] ?? 'User deleted successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to delete user: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to delete user.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error deleting user: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting the user.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchDelete(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to delete users.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$uuids = $request->input('admin_uuid', []);
|
||||||
|
|
||||||
|
if (empty($uuids)) {
|
||||||
|
return redirect()->back()->with('error', 'No users selected for deletion.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::info('Batch delete UUIDs: ', $uuids);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/adminBatchDelete", [
|
||||||
|
'admin_uuid' => $uuids,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Batch delete successful for UUIDs: ', $uuids);
|
||||||
|
return redirect()->route('user.management')
|
||||||
|
->with('success', $json['message'] ?? 'Users deleted successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to batch delete users: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to delete users.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error in batch delete: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while deleting users.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function changeStatus(Request $request, $uuid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Session::get('user');
|
||||||
|
$accessToken = $user['access_token'] ?? null;
|
||||||
|
|
||||||
|
if (!$accessToken) {
|
||||||
|
return redirect()->route('login')->with('error', 'Please log in to change user status.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'status' => 'required|in:active,inactive',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'admin_uuid' => $uuid,
|
||||||
|
'status' => $validated['status'],
|
||||||
|
];
|
||||||
|
|
||||||
|
Log::info('API Payload for changing status: ', $payload);
|
||||||
|
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => 'Bearer ' . $accessToken,
|
||||||
|
])->post("{$this->apiBaseUrl}/cms/adminChangeStatus", $payload);
|
||||||
|
|
||||||
|
$json = $response->json();
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Log::info('Status changed successfully for UUID: ' . $uuid);
|
||||||
|
return redirect()->route('user.management')
|
||||||
|
->with('success', $json['message'] ?? 'Status updated successfully');
|
||||||
|
} else {
|
||||||
|
Log::error('Failed to change status: ', $json);
|
||||||
|
return redirect()->back()->with('error', $json['message'] ?? 'Failed to update status.');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error changing status: ' . $e->getMessage());
|
||||||
|
return redirect()->back()->with('error', 'An error occurred while changing status.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class UserViewController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||||
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for serialization.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
'password' => 'hashed',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\View;
|
||||||
|
use App\View\Composers\UserViewComposer;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
// Share authenticated user with the 'layouts.app' view
|
||||||
|
View::composer('layouts.app', UserViewComposer::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class ApiService
|
||||||
|
{
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->baseUrl = rtrim(env('API_URL', '/'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fetchData($url, $token = null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . ($token ?: Session::get('token', '')),
|
||||||
|
])->get($this->baseUrl . $url);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return $response->json();
|
||||||
|
} else {
|
||||||
|
$this->handleError($response);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('API Fetch Error: ' . $e->getMessage());
|
||||||
|
Session::flash('error', 'Failed to fetch data: ' . $e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout($token = null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$response = Http::withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . ($token ?: Session::get('token', '')),
|
||||||
|
])->get($this->baseUrl . '/logout');
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
Session::forget('token');
|
||||||
|
Session::flash('success', 'Logged out successfully.');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->handleError($response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Logout Error: ' . $e->getMessage());
|
||||||
|
Session::flash('error', 'Logout failed: ' . $e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleError($response)
|
||||||
|
{
|
||||||
|
$status = $response->status();
|
||||||
|
|
||||||
|
if ($status === 401) {
|
||||||
|
Session::forget('token');
|
||||||
|
throw new \Exception('Session expired. Please login again.');
|
||||||
|
} elseif ($status === 404) {
|
||||||
|
throw new \Exception('API resource not found.');
|
||||||
|
} else {
|
||||||
|
throw new \Exception('API error: ' . ($response->body() ?: 'Unknown error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function get($url, $params = [])
|
||||||
|
// {
|
||||||
|
// $token = $this->cookieService->getCookie()['token'] ?? null;
|
||||||
|
// $this->defaultHeaders['Authorization'] = 'Bearer ' . $token;
|
||||||
|
// return $this->makeRequest('get', $url, $params);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function post($url, $params = [])
|
||||||
|
// {
|
||||||
|
// return $this->makeRequest('post', $url, $params);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function get(string $endpoint, array $query = [])
|
||||||
|
{
|
||||||
|
return Http::get("{$this->baseUrl}/{$endpoint}", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function post(string $endpoint, array $data = [])
|
||||||
|
{
|
||||||
|
return Http::post("{$this->baseUrl}/{$endpoint}", $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function put($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('put', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('delete', $url, ['params' => $params]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postMultipart($url, $data)
|
||||||
|
{
|
||||||
|
return $this->makeRequest('postMultipart', $url, $data);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Livewire\ErrorHandler;
|
||||||
|
|
||||||
|
class BaseApiService
|
||||||
|
{
|
||||||
|
protected $baseUrl;
|
||||||
|
protected $defaultHeaders = [];
|
||||||
|
|
||||||
|
public function __construct(string $baseUrl)
|
||||||
|
{
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function makeRequest($method, $url, $params = [], $headers = [])
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$fullHeaders = array_merge($this->defaultHeaders, $headers, [
|
||||||
|
'Authorization' => 'Bearer ' . Session::get('token', ''),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders($fullHeaders)->{$method}($this->baseUrl . $url, $params);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return $response->json();
|
||||||
|
} else {
|
||||||
|
$this->handleError($response);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('API Request Error: ' . $e->getMessage());
|
||||||
|
Session::flash('error', 'API request failed: ' . $e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleError($response)
|
||||||
|
{
|
||||||
|
$status = $response->status();
|
||||||
|
|
||||||
|
if ($status === 401) {
|
||||||
|
Session::forget('token');
|
||||||
|
throw new \Exception('Session expired. Please login again.');
|
||||||
|
} elseif ($status === 422) {
|
||||||
|
throw new \Exception('Validation error: ' . ($response->body() ?: 'Unknown validation error'));
|
||||||
|
} elseif ($status === 404) {
|
||||||
|
throw new \Exception('API resource not found.');
|
||||||
|
} else {
|
||||||
|
throw new \Exception('API error: ' . ($response->body() ?: 'Unknown error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postMultipart($url, $data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$headers = array_merge($this->defaultHeaders, [
|
||||||
|
'Authorization' => 'Bearer ' . Session::get('token', ''),
|
||||||
|
'Content-Type' => 'multipart/form-data',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = Http::withHeaders($headers)->asMultipart();
|
||||||
|
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
if ($value instanceof \Illuminate\Http\UploadedFile) {
|
||||||
|
$response = $response->attach($key, $value->get(), $value->getClientOriginalName());
|
||||||
|
} else {
|
||||||
|
$response = $response->attach($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $response->post($this->baseUrl . $url);
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
return $response->json();
|
||||||
|
} else {
|
||||||
|
$this->handleError($response);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Multipart API Request Error: ' . $e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Cookie;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CookieService
|
||||||
|
{
|
||||||
|
const COOKIE_NAME = 'FRONT_END_REST';
|
||||||
|
const PUBLIC_KEY = 'PUBLIC_00001';
|
||||||
|
const TIME_OUT_HOURS = 1; // 60 minutes
|
||||||
|
|
||||||
|
public function setCookie(array $params, string $name = self::COOKIE_NAME): bool
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!is_array($params)) {
|
||||||
|
throw new \TypeError('setCookie params should be an array.', 'CookieService.php', 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
$expiration = now()->addHours(self::TIME_OUT_HOURS);
|
||||||
|
$encryptedValue = Crypt::encryptString(json_encode($params));
|
||||||
|
|
||||||
|
Cookie::queue($name, $encryptedValue, $expiration->diffInMinutes(), '/', null, false, true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Cookie Set Error: ' . $e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCookie(string $name = self::COOKIE_NAME)
|
||||||
|
{
|
||||||
|
$cookie = Cookie::get($name);
|
||||||
|
|
||||||
|
if (!$cookie) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return json_decode(Crypt::decryptString($cookie), true);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Cookie Get Error: ' . $e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeCookie(string $name = self::COOKIE_NAME): bool
|
||||||
|
{
|
||||||
|
Cookie::queue(Cookie::forget($name));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class EncryptionService
|
||||||
|
{
|
||||||
|
const ALGORITHM = 'aes-256-ctr';
|
||||||
|
private $password;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->password = $this->getPasswordFromCookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPasswordFromCookie()
|
||||||
|
{
|
||||||
|
$cookieService = app(CookieService::class);
|
||||||
|
$cookie = $cookieService->getCookie(process.env.REACT_APP_TOKEN ?? 'token');
|
||||||
|
return $cookie['token'] ?? 'default_password'; // Fallback if token not found
|
||||||
|
}
|
||||||
|
|
||||||
|
public function encrypt(string $text): string
|
||||||
|
{
|
||||||
|
$iv = random_bytes(16); // Initialization vector
|
||||||
|
$encrypted = openssl_encrypt($text, self::ALGORITHM, $this->password, 0, $iv);
|
||||||
|
return base64_encode($iv . $encrypted); // Combine IV and encrypted data
|
||||||
|
}
|
||||||
|
|
||||||
|
public function decrypt(string $text): string|bool
|
||||||
|
{
|
||||||
|
$data = base64_decode($text);
|
||||||
|
$iv = substr($data, 0, 16);
|
||||||
|
$encrypted = substr($data, 16);
|
||||||
|
|
||||||
|
$decrypted = openssl_decrypt($encrypted, self::ALGORITHM, $this->password, 0, $iv);
|
||||||
|
|
||||||
|
if ($decrypted === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the result is hexadecimal (simulating your JS check)
|
||||||
|
if (preg_match('/^[0-9a-fA-F]+$/', $decrypted)) {
|
||||||
|
return $decrypted;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
class NotificationApiService extends BaseApiService
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct(config('app.notif_api_base_url'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNotification($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('get', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postNotification($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('post', $url, $params);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
class StationApiService extends BaseApiService
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct(config('app.station_api_base_url'));
|
||||||
|
$this->defaultHeaders = array_merge($this->defaultHeaders, [
|
||||||
|
'X-Requested-With' => 'station-locator-api',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBranch($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('get', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postBranch($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('post', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function putBranch($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('put', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteBranch($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('delete', $url, ['params' => $params]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postFuel($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('post', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function putFuel($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('put', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFuels($url, $params = [])
|
||||||
|
{
|
||||||
|
return $this->makeRequest('get', $url, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCsv($url, $params = [])
|
||||||
|
{
|
||||||
|
return Http::withHeaders(array_merge($this->defaultHeaders, [
|
||||||
|
'Authorization' => 'Bearer ' . Session::get('token', ''),
|
||||||
|
]))->get($this->baseUrl . $url, $params)->body(); // Return raw text for CSV
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Composers;
|
||||||
|
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class UserViewComposer
|
||||||
|
{
|
||||||
|
public function compose(View $view)
|
||||||
|
{
|
||||||
|
// Retrieve the user data from the session, default to null if not set
|
||||||
|
$user = Session::get('user', null);
|
||||||
|
|
||||||
|
// Share the user data with the view
|
||||||
|
$view->with('user', $user);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
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...
|
||||||
|
$status = (require_once __DIR__.'/bootstrap/app.php')
|
||||||
|
->handleCommand(new ArgvInput);
|
||||||
|
|
||||||
|
exit($status);
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
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',
|
||||||
|
commands: __DIR__.'/../routes/console.php',
|
||||||
|
health: '/up',
|
||||||
|
)
|
||||||
|
->withMiddleware(function (Middleware $middleware) {
|
||||||
|
//
|
||||||
|
})
|
||||||
|
->withExceptions(function (Exceptions $exceptions) {
|
||||||
|
//
|
||||||
|
})->create();
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
];
|
|
@ -0,0 +1,74 @@
|
||||||
|
{
|
||||||
|
"$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",
|
||||||
|
"guzzlehttp/guzzle": "^7.9",
|
||||||
|
"laravel/framework": "^11.31",
|
||||||
|
"laravel/tinker": "^2.9",
|
||||||
|
"laravel/ui": "^4.6",
|
||||||
|
"livewire/livewire": "^3.6"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.23",
|
||||||
|
"laravel/pail": "^1.1",
|
||||||
|
"laravel/pint": "^1.13",
|
||||||
|
"laravel/sail": "^1.26",
|
||||||
|
"mockery/mockery": "^1.6",
|
||||||
|
"nunomaduro/collision": "^8.1",
|
||||||
|
"phpunit/phpunit": "^11.0.1"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"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"
|
||||||
|
],
|
||||||
|
"dev": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"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,127 @@
|
||||||
|
<?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'),
|
||||||
|
'api_base_url' => env('API_BASE_URL', 'http://192.168.100.6:8081'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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' => env('APP_TIMEZONE', 'UTC'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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(',', 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,115 @@
|
||||||
|
<?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',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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),
|
||||||
|
],
|
||||||
|
|
||||||
|
// 'users' => [
|
||||||
|
// 'driver' => 'database',
|
||||||
|
// 'table' => 'users',
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 amount 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,108 @@
|
||||||
|
<?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_DRIVER', 'file'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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", "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',
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,173 @@
|
||||||
|
<?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,
|
||||||
|
],
|
||||||
|
|
||||||
|
'mysql' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', 'db_mysql'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'armie-database'),
|
||||||
|
'username' => env('DB_USERNAME', 'rootuser'),
|
||||||
|
'password' => env('DB_PASSWORD', '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([
|
||||||
|
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([
|
||||||
|
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' => '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(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'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'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'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'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -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' => env('APP_URL').'/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,160 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Class Namespace
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value sets the root class namespace for Livewire component classes in
|
||||||
|
| your application. This value will change where component auto-discovery
|
||||||
|
| finds components. It's also referenced by the file creation commands.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'class_namespace' => 'App\\Livewire',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| View Path
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value is used to specify where Livewire component Blade templates are
|
||||||
|
| stored when running file creation commands like `artisan make:livewire`.
|
||||||
|
| It is also used if you choose to omit a component's render() method.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'view_path' => resource_path('views/livewire'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Layout
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| The view that will be used as the layout when rendering a single component
|
||||||
|
| as an entire page via `Route::get('/post/create', CreatePost::class);`.
|
||||||
|
| In this case, the view returned by CreatePost will render into $slot.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'layout' => 'components.layouts.app',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Lazy Loading Placeholder
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Livewire allows you to lazy load components that would otherwise slow down
|
||||||
|
| the initial page load. Every component can have a custom placeholder or
|
||||||
|
| you can define the default placeholder view for all components below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lazy_placeholder' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Temporary File Uploads
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Livewire handles file uploads by storing uploads in a temporary directory
|
||||||
|
| before the file is stored permanently. All file uploads are directed to
|
||||||
|
| a global endpoint for temporary storage. You may configure this below:
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'temporary_file_upload' => [
|
||||||
|
'disk' => null, // Example: 'local', 's3' | Default: 'default'
|
||||||
|
'rules' => null, // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB)
|
||||||
|
'directory' => null, // Example: 'tmp' | Default: 'livewire-tmp'
|
||||||
|
'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1'
|
||||||
|
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs...
|
||||||
|
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
|
||||||
|
'mov', 'avi', 'wmv', 'mp3', 'm4a',
|
||||||
|
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
|
||||||
|
],
|
||||||
|
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
|
||||||
|
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Render On Redirect
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines if Livewire will run a component's `render()` method
|
||||||
|
| after a redirect has been triggered using something like `redirect(...)`
|
||||||
|
| Setting this to true will render the view once more before redirecting
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'render_on_redirect' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Eloquent Model Binding
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Previous versions of Livewire supported binding directly to eloquent model
|
||||||
|
| properties using wire:model by default. However, this behavior has been
|
||||||
|
| deemed too "magical" and has therefore been put under a feature flag.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'legacy_model_binding' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Auto-inject Frontend Assets
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default, Livewire automatically injects its JavaScript and CSS into the
|
||||||
|
| <head> and <body> of pages containing Livewire components. By disabling
|
||||||
|
| this behavior, you need to use @livewireStyles and @livewireScripts.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'inject_assets' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Navigate (SPA mode)
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By adding `wire:navigate` to links in your Livewire application, Livewire
|
||||||
|
| will prevent the default link handling and instead request those pages
|
||||||
|
| via AJAX, creating an SPA-like effect. Configure this behavior here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'navigate' => [
|
||||||
|
'show_progress_bar' => true,
|
||||||
|
'progress_bar_color' => '#2299dd',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| HTML Morph Markers
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Livewire intelligently "morphs" existing HTML into the newly rendered HTML
|
||||||
|
| after each update. To make this process more reliable, Livewire injects
|
||||||
|
| "markers" into the rendered Blade surrounding @if, @class & @foreach.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'inject_morph_markers' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
| Pagination Theme
|
||||||
|
|---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When enabling Livewire's pagination feature by using the `WithPagination`
|
||||||
|
| trait, Livewire will use Tailwind templates to render pagination views
|
||||||
|
| on the page. If you want Bootstrap CSS, you can specify: "bootstrap"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'pagination_theme' => 'tailwind',
|
||||||
|
];
|
|
@ -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(',', 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,
|
||||||
|
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||||
|
'with' => [
|
||||||
|
'stream' => 'php://stderr',
|
||||||
|
],
|
||||||
|
'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,116 @@
|
||||||
|
<?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(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',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'roundrobin' => [
|
||||||
|
'transport' => 'roundrobin',
|
||||||
|
'mailers' => [
|
||||||
|
'ses',
|
||||||
|
'postmark',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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,112 @@
|
||||||
|
<?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", "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,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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,43 @@
|
||||||
|
<?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' => [
|
||||||
|
'token' => env('POSTMARK_TOKEN'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'key' => env('RESEND_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'notifications' => [
|
||||||
|
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||||
|
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'backend_api' => [
|
||||||
|
'url' => 'http://192.168.100.6:8081', // Use the backend container name and internal port
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
];
|
|
@ -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", "apc",
|
||||||
|
| "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: "apc", "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(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 and all 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),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1 @@
|
||||||
|
*.sqlite*
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||||
|
*/
|
||||||
|
class UserFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The current password being used by the factory.
|
||||||
|
*/
|
||||||
|
protected static ?string $password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => fake()->name(),
|
||||||
|
'email' => fake()->unique()->safeEmail(),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
|
'remember_token' => Str::random(10),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model's email address should be unverified.
|
||||||
|
*/
|
||||||
|
public function unverified(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn (array $attributes) => [
|
||||||
|
'email_verified_at' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('sessions', function (Blueprint $table) {
|
||||||
|
$table->string('id')->primary();
|
||||||
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
|
$table->string('ip_address', 45)->nullable();
|
||||||
|
$table->text('user_agent')->nullable();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->integer('last_activity')->index();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sessions');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Seed the application's database.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// User::factory(10)->create();
|
||||||
|
|
||||||
|
User::factory()->create([
|
||||||
|
'name' => 'Test User',
|
||||||
|
'email' => 'test@example.com',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: ./docker/php
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: frontend-app
|
||||||
|
restart: always
|
||||||
|
working_dir: /var/www
|
||||||
|
volumes:
|
||||||
|
- .:/var/www
|
||||||
|
|
||||||
|
command: >
|
||||||
|
/bin/sh -c 'mkdir -p /var/www/storage /var/www/bootstrap/cache &&
|
||||||
|
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache &&
|
||||||
|
chmod -R 775 /var/www/storage /var/www/bootstrap/cache &&
|
||||||
|
composer install --no-dev --optimize-autoloader &&
|
||||||
|
php-fpm'
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "sh", "-c", "netstat -an | grep 9000 > /dev/null || exit 1" ]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 10
|
||||||
|
networks:
|
||||||
|
- frontend-network
|
||||||
|
- unioil-loyalty-app_backend-network
|
||||||
|
environment:
|
||||||
|
- DB_HOST=db_mysql
|
||||||
|
- DB_PORT=3306
|
||||||
|
- DB_DATABASE=armie-database
|
||||||
|
- DB_USERNAME=rootuser
|
||||||
|
- DB_PASSWORD=password
|
||||||
|
- CACHE_DRIVER=file
|
||||||
|
- API_URL=http://backend-web:8081
|
||||||
|
|
||||||
|
web-frontend:
|
||||||
|
image: nginx:1.26.3-alpine
|
||||||
|
container_name: web-frontend
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
expose:
|
||||||
|
- "80"
|
||||||
|
volumes:
|
||||||
|
- .:/var/www
|
||||||
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
depends_on:
|
||||||
|
app:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "curl", "-f", "http://localhost" ]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
networks:
|
||||||
|
- frontend-network
|
||||||
|
- unioil-loyalty-app_backend-network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
frontend-network:
|
||||||
|
driver: bridge
|
||||||
|
unioil-loyalty-app_backend-network:
|
||||||
|
external: true
|
|
@ -0,0 +1,24 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /var/www/public;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass frontend-app:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
FROM php:8.3-fpm
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libpng-dev \
|
||||||
|
libjpeg-dev \
|
||||||
|
libfreetype6-dev \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
libzip-dev \
|
||||||
|
net-tools \
|
||||||
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||||
|
&& docker-php-ext-install gd pdo pdo_mysql zip
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /var/www
|
||||||
|
|
||||||
|
# Copy application code
|
||||||
|
COPY . /var/www
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chown -R www-data:www-data /var/www \
|
||||||
|
&& chmod -R 755 /var/www
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 9000
|
||||||
|
|
||||||
|
CMD ["php-fpm"]
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Exit script on any error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Ensure we're in the right directory
|
||||||
|
cd /var/www/html
|
||||||
|
|
||||||
|
# Install PHP dependencies
|
||||||
|
composer install --no-dev --optimize-autoloader
|
||||||
|
|
||||||
|
# Install Node.js dependencies if node_modules not present
|
||||||
|
if [ ! -d "node_modules" ]; then
|
||||||
|
npm install
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build frontend assets
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# Set correct permissions for storage and cache
|
||||||
|
chown -R www-data:www-data storage bootstrap/cache
|
||||||
|
chmod -R 775 storage bootstrap/
|
||||||
|
|
||||||
|
# Run database migrations
|
||||||
|
php artisan migrate --force
|
||||||
|
|
||||||
|
# Start PHP-FPM
|
||||||
|
php-fpm
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Frontend</title>
|
||||||
|
<script type="module" src="/resources/js/app.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<h1>Loading...</h1>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "vite build",
|
||||||
|
"dev": "vite"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@popperjs/core": "^2.11.6",
|
||||||
|
"autoprefixer": "^10.4.20",
|
||||||
|
"axios": "^1.9.0",
|
||||||
|
"bootstrap": "^5.2.3",
|
||||||
|
"concurrently": "^9.0.1",
|
||||||
|
"laravel-vite-plugin": "^1.2.0",
|
||||||
|
"postcss": "^8.4.47",
|
||||||
|
"sass": "^1.56.1",
|
||||||
|
"sass-embedded": "^1.87.0",
|
||||||
|
"tailwindcss": "^3.4.13",
|
||||||
|
"vite": "^6.3.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@popperjs/core": "^2.11.8",
|
||||||
|
"bootstrap": "^5.3.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Unit">
|
||||||
|
<directory>tests/Unit</directory>
|
||||||
|
</testsuite>
|
||||||
|
<testsuite name="Feature">
|
||||||
|
<directory>tests/Feature</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory>app</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
<php>
|
||||||
|
<env name="APP_ENV" value="testing"/>
|
||||||
|
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||||
|
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||||
|
<env name="CACHE_STORE" value="array"/>
|
||||||
|
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
|
||||||
|
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
|
||||||
|
<env name="MAIL_MAILER" value="array"/>
|
||||||
|
<env name="PULSE_ENABLED" value="false"/>
|
||||||
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
|
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||||
|
</php>
|
||||||
|
</phpunit>
|
|
@ -0,0 +1,6 @@
|
||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,25 @@
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
<IfModule mod_negotiation.c>
|
||||||
|
Options -MultiViews -Indexes
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# Handle Authorization Header
|
||||||
|
RewriteCond %{HTTP:Authorization} .
|
||||||
|
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
|
||||||
|
# Handle X-XSRF-Token Header
|
||||||
|
RewriteCond %{HTTP:x-xsrf-token} .
|
||||||
|
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
|
||||||
|
|
||||||
|
# Redirect Trailing Slashes If Not A Folder...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_URI} (.+)/$
|
||||||
|
RewriteRule ^ %1 [L,R=301]
|
||||||
|
|
||||||
|
# Send Requests To Front Controller...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
||||||
|
</IfModule>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,3 @@
|
||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,779 @@
|
||||||
|
@import url('https://fonts.googleapis.com/css?family=Nova+Slim&display=swap');
|
||||||
|
|
||||||
|
body,
|
||||||
|
html {
|
||||||
|
line-height: 1.8;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||||
|
color: #555e58;
|
||||||
|
text-transform: capitalize;
|
||||||
|
text-rendering: optimizeLegibility !important;
|
||||||
|
-webkit-font-smoothing: antialiased !important;
|
||||||
|
font-weight: 400;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6,
|
||||||
|
.h1,
|
||||||
|
.h2,
|
||||||
|
.h3,
|
||||||
|
.h4 {
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 15px;
|
||||||
|
margin: 12px 0 0;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #333;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:focus {
|
||||||
|
box-shadow: none;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul,
|
||||||
|
ol {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0px;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
a,
|
||||||
|
a:hover,
|
||||||
|
a:focus {
|
||||||
|
color: #333;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*=======================================================
|
||||||
|
material-icons copy & paste form site google material-icons
|
||||||
|
==================================================*/
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Material Icons';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src: url(https://example.com/MaterialIcons-Regular.eot);
|
||||||
|
/* For IE6-8 */
|
||||||
|
src: local('Material Icons'),
|
||||||
|
local('MaterialIcons-Regular'),
|
||||||
|
url(https://example.com/MaterialIcons-Regular.woff2) format('woff2'),
|
||||||
|
url(https://example.com/MaterialIcons-Regular.woff) format('woff'),
|
||||||
|
url(https://example.com/MaterialIcons-Regular.ttf) format('truetype');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.material-icons {
|
||||||
|
font-family: 'Material Icons';
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 24px;
|
||||||
|
/* Preferred icon size */
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 1;
|
||||||
|
text-transform: none;
|
||||||
|
letter-spacing: normal;
|
||||||
|
word-wrap: normal;
|
||||||
|
white-space: nowrap;
|
||||||
|
direction: ltr;
|
||||||
|
|
||||||
|
/* Support for all WebKit browsers. */
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
/* Support for Safari and Chrome. */
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
|
||||||
|
/* Support for Firefox. */
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
|
||||||
|
/* Support for IE. */
|
||||||
|
font-feature-settings: 'liga';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=======================================================
|
||||||
|
material-icons copy & paste form site google material-icons
|
||||||
|
==================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------
|
||||||
|
SIDEBAR STYLE start
|
||||||
|
----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#sidebar {
|
||||||
|
position: fixed;
|
||||||
|
height: 100vh !important;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 11;
|
||||||
|
width: 260px;
|
||||||
|
overflow: auto;
|
||||||
|
transition: all 0.3s;
|
||||||
|
background: #FFFFFF;
|
||||||
|
box-shadow: 0 10px 30px -12px rgb(0 0 0 / 42%), 0 4px 25px 0px rgb(0 0 0 / 12%), 0 8px 10px -5px rgb(0 0 0 / 20%);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#sidebar::-webkit-scrollbar {
|
||||||
|
width: 5px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: #eee;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar::-webkit-scrollbar-thumbs {
|
||||||
|
width: 5px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: #333;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#sidebar:hover::-webkit-scrollbar {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar:hover::-webkit-scrollbar-thumbs {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar .sidebar-header {
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-header h3 {
|
||||||
|
color: #333;
|
||||||
|
font-size: 17px;
|
||||||
|
margin: 0px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-header h3 img {
|
||||||
|
width: 120px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul li {
|
||||||
|
padding: 2px 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul li.active>a {
|
||||||
|
color: #333;
|
||||||
|
background-color: rgba(200, 200, 200, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul li a:hover {
|
||||||
|
color: #333;
|
||||||
|
background-color: rgba(200, 200, 200, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-toggle::after {
|
||||||
|
position: absolute;
|
||||||
|
right: 10px;
|
||||||
|
top: 23px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul li.drodown {
|
||||||
|
position: sticky;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#sidebar ul.components {
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul li a {
|
||||||
|
padding: 10px;
|
||||||
|
line-height: 30px;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 15px;
|
||||||
|
position: relative;
|
||||||
|
font-weight: 400;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul li a span {
|
||||||
|
text-transform: capitalize;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar ul li a i {
|
||||||
|
position: relative;
|
||||||
|
margin-right: 10px;
|
||||||
|
top: 5px;
|
||||||
|
color: #555555;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------
|
||||||
|
sidebar end
|
||||||
|
----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*=======================================================
|
||||||
|
main-content navbar-design start
|
||||||
|
===============================================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#content {
|
||||||
|
position: relative;
|
||||||
|
transition: all 0.3s;
|
||||||
|
background-color: #EEEEEE;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-navbar {
|
||||||
|
width: 100%;
|
||||||
|
z-index: 9;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
padding: 10px 20px 0px 20px;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
background-color: #2196F3;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar button {
|
||||||
|
background-color: transparent;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar button span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebarCollapse {
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 45px;
|
||||||
|
height: 45px;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 45px;
|
||||||
|
margin-right: 20px;
|
||||||
|
border: none;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: rgba(0, 0, 0, 0.09);
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebarCollapse span {
|
||||||
|
margin: 9px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.navbar-nav>li.active {
|
||||||
|
color: #FFFFFF;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-nav>li>a {
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.navbar .notification {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 10px;
|
||||||
|
display: block;
|
||||||
|
font-size: 9px;
|
||||||
|
border: 0px;
|
||||||
|
font-size: 10px;
|
||||||
|
background: #d9534f;
|
||||||
|
min-width: 15px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 1px 5px;
|
||||||
|
height: 15px;
|
||||||
|
border-radius: 2px;
|
||||||
|
line-height: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.navbar-nav>li.show .dropdown-menu {
|
||||||
|
transform: translate3d(0, 0, 0);
|
||||||
|
opacity: 1;
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.dropdown-menu li>a {
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
margin: 0 5px;
|
||||||
|
border-radius: 2px;
|
||||||
|
font-weight: 400;
|
||||||
|
transition: all 150ms linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-nav>.active>a:focus {
|
||||||
|
color: #FFFFFF;
|
||||||
|
background-color: rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.navbar-nav li a {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
padding: 10px 15px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=======================================================
|
||||||
|
main-content navbar-design end
|
||||||
|
===============================================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*=======================================================
|
||||||
|
main-content navbar-design start
|
||||||
|
===============================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/*=======================================================
|
||||||
|
main-content inner design like card start
|
||||||
|
===============================================*/
|
||||||
|
|
||||||
|
|
||||||
|
.card {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border-radius: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
border: none !important;
|
||||||
|
width: 100%;
|
||||||
|
margin: 15px 0;
|
||||||
|
box-shadow: 0 1px 2px rgb(0 0 0 / 8%);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: rgba(0, 0, 0, 0.87);
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-stats .card-header {
|
||||||
|
float: left;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-header {
|
||||||
|
padding: 15px 20px 0;
|
||||||
|
z-index: 3;
|
||||||
|
background-color: #fff !important;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-footer .stats .material-icons {
|
||||||
|
position: relative;
|
||||||
|
top: 4px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-stats .card-header span {
|
||||||
|
font-size: 36px;
|
||||||
|
line-height: 56px;
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon.icon-warning {
|
||||||
|
color: #ff9800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon.icon-rose {
|
||||||
|
color: #e91e63;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon.icon-success {
|
||||||
|
color: #4caf50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon.icon-info {
|
||||||
|
color: #00bcd4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-footer {
|
||||||
|
margin: 0 7px 0px;
|
||||||
|
padding-top: 10px;
|
||||||
|
background-color: #fff;
|
||||||
|
border-top: 1px solid #eeeeee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-info {
|
||||||
|
color: #03A9F4 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-stats .card-content {
|
||||||
|
text-align: right;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-content {
|
||||||
|
padding: 15px 20px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-content .category {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .category:not([class*="text-"]) {
|
||||||
|
color: #555555;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-title:not(.card-calendar .card-title) {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-stats .card-title {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-footer .stats {
|
||||||
|
line-height: 22px;
|
||||||
|
color: #555555;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-footer div {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card .card-header-text h4 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 3px;
|
||||||
|
font-size: 19px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #222222;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.table>thead>tr>th {
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.card .card-content {
|
||||||
|
padding: 15px 20px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-primary {
|
||||||
|
border-left-color: #188ae2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-item {
|
||||||
|
position: relative;
|
||||||
|
padding-bottom: 12px;
|
||||||
|
border-left: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.streamline .sl-item:before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: -6px;
|
||||||
|
top: 0;
|
||||||
|
background-color: #ccc;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
border-radius: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-primary:before,
|
||||||
|
.streamline .sl-primary:last-child:after {
|
||||||
|
background-color: #188ae2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.streamline .sl-danger:before,
|
||||||
|
.streamline .sl-danger:last-child:after {
|
||||||
|
background-color: #ff5b5b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-success {
|
||||||
|
border-left-color: #10c469;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-success:before,
|
||||||
|
.streamline .sl-success:last-child:after {
|
||||||
|
background-color: #10c469;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-warning {
|
||||||
|
border-left-color: #f9c851;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-warning:before,
|
||||||
|
.streamline .sl-warning:last-child:after {
|
||||||
|
background-color: #f9c851;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.streamline .sl-danger {
|
||||||
|
border-left-color: #ff5b5b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-item .sl-content {
|
||||||
|
margin-left: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-item .text-muted {
|
||||||
|
color: inherit;
|
||||||
|
opacity: .6;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamline .sl-item p {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=======================================================
|
||||||
|
main-content inner design like card end
|
||||||
|
===============================================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*=============================================
|
||||||
|
footer design start
|
||||||
|
=========================================*/
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
border-top: 1px solid #e7e7e7;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
padding: 10px 0;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer ul li {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer ul li a {
|
||||||
|
color: inherit;
|
||||||
|
padding: 15px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 12px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
border-radius: 3px;
|
||||||
|
text-decoration: none;
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
footer .copyright {
|
||||||
|
padding: 15px;
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=============================================
|
||||||
|
footer design end
|
||||||
|
=========================================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#sidebar.show-nav,
|
||||||
|
.body-overlay.show-nav {
|
||||||
|
transform: translatex(0%);
|
||||||
|
opacity: 1;
|
||||||
|
display: block;
|
||||||
|
visibility: visible;
|
||||||
|
z-index: 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------
|
||||||
|
MEDIAQUERIES
|
||||||
|
----------------------------------------------------- */
|
||||||
|
|
||||||
|
@media only screen and (min-width:992px) {
|
||||||
|
#sidebar.active {
|
||||||
|
width: 80px;
|
||||||
|
height: 100% !important;
|
||||||
|
position: absolute !important;
|
||||||
|
overflow: visible !important;
|
||||||
|
top: 0 !important;
|
||||||
|
z-index: 666;
|
||||||
|
float: left !important;
|
||||||
|
bottom: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#sidebar.active .sidebar-header h3 span {
|
||||||
|
display: none;
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar.active ul li a span {
|
||||||
|
display: none;
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar.active .dropdown-toggle::after {
|
||||||
|
display: none;
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
width: calc(100% - 260px);
|
||||||
|
position: relative;
|
||||||
|
float: right;
|
||||||
|
transition: all 0.3s;
|
||||||
|
background-color: #EEEEEE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content.active {
|
||||||
|
width: calc(100% - 80px);
|
||||||
|
}
|
||||||
|
|
||||||
|
#sidebar.active .menu {
|
||||||
|
position: absolute;
|
||||||
|
left: 81px;
|
||||||
|
background-color: white;
|
||||||
|
width: 180px;
|
||||||
|
height: auto;
|
||||||
|
margin: 5px 0;
|
||||||
|
top: 0;
|
||||||
|
border: 1px solid #dcd9d9;
|
||||||
|
z-index: 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@media only screen and (min-width:992px) {
|
||||||
|
.dropdown-menu {
|
||||||
|
border: 0;
|
||||||
|
box-shadow: 0 2px 5px 0 rgb(0 0 0 / 26%);
|
||||||
|
transform: translate3d(0, -20px, 0);
|
||||||
|
visibility: hidden;
|
||||||
|
transition: all 150ms linear;
|
||||||
|
display: block;
|
||||||
|
min-width: 15rem;
|
||||||
|
right: 0;
|
||||||
|
left: auto;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*===============small-screen overlay sidebar design media queries==============*/
|
||||||
|
|
||||||
|
@media only screen and (max-width:992px) {
|
||||||
|
#sidebar {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 10;
|
||||||
|
width: 260px;
|
||||||
|
transform: translatex(-100%);
|
||||||
|
transition: all 150ms linear;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.body-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: none;
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
z-index: 3;
|
||||||
|
transition: all 150ms linear;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===============small-screen overlay sidebar design media queries==============*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------
|
||||||
|
MEDIAQUERIES
|
||||||
|
----------------------------------------------------- */
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,129 @@
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0; }
|
||||||
|
|
||||||
|
*,
|
||||||
|
::after,
|
||||||
|
::before {
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
box-sizing: border-box; }
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
-webkit-transition: all 0.5s ease-in-out 0s;
|
||||||
|
-o-transition: all 0.5s ease-in-out 0s;
|
||||||
|
transition: all 0.5s ease-in-out 0s; }
|
||||||
|
a:hover {
|
||||||
|
text-decoration: none; }
|
||||||
|
|
||||||
|
/*-----------------------------
|
||||||
|
News Ticker
|
||||||
|
------------------------------*/
|
||||||
|
.acme-news-ticker {
|
||||||
|
background: #fff;
|
||||||
|
position: relative;
|
||||||
|
height: 45px;
|
||||||
|
border: 1px solid #1974d2;
|
||||||
|
margin-top: 45px; }
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.acme-news-ticker {
|
||||||
|
margin-top: 0; } }
|
||||||
|
.acme-news-ticker-label {
|
||||||
|
background: #1974d2;
|
||||||
|
padding: 10px;
|
||||||
|
width: auto;
|
||||||
|
float: left;
|
||||||
|
margin-right: 15px;
|
||||||
|
line-height: normal;
|
||||||
|
height: 100%;
|
||||||
|
color: #fff; }
|
||||||
|
@media (max-width: 575px) {
|
||||||
|
.acme-news-ticker-label {
|
||||||
|
position: absolute;
|
||||||
|
top: -45px; } }
|
||||||
|
.acme-news-ticker-box {
|
||||||
|
height: 100%;
|
||||||
|
padding-top: 10px;
|
||||||
|
overflow: hidden; }
|
||||||
|
@media (max-width: 575px) {
|
||||||
|
.acme-news-ticker-box {
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 120px; } }
|
||||||
|
.acme-news-ticker-box ul {
|
||||||
|
width: 100%;
|
||||||
|
list-style-type: none !important;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0; }
|
||||||
|
.acme-news-ticker-box ul li a {
|
||||||
|
text-decoration: none; }
|
||||||
|
.acme-news-ticker-controls {
|
||||||
|
display: -webkit-box;
|
||||||
|
display: -ms-flexbox;
|
||||||
|
display: flex;
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
right: 0;
|
||||||
|
top: 0; }
|
||||||
|
.acme-news-ticker-controls button {
|
||||||
|
height: 100%;
|
||||||
|
background: #f6f6f6;
|
||||||
|
padding: 0;
|
||||||
|
width: 40px;
|
||||||
|
border-color: #eeeeee;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 0 0 0 1px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block; }
|
||||||
|
.acme-news-ticker-controls button:hover {
|
||||||
|
background: #eeeeee; }
|
||||||
|
.acme-news-ticker-controls button.acme-news-ticker-arrow {
|
||||||
|
margin: 0;
|
||||||
|
display: inline-block;
|
||||||
|
position: relative; }
|
||||||
|
.acme-news-ticker-controls button.acme-news-ticker-arrow:after {
|
||||||
|
border-color: #999;
|
||||||
|
border-bottom-style: solid;
|
||||||
|
border-bottom-width: 2px;
|
||||||
|
border-right-style: solid;
|
||||||
|
border-right-width: 2px;
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
height: 8px;
|
||||||
|
left: 50%;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
width: 8px; }
|
||||||
|
.acme-news-ticker-controls button.acme-news-ticker-pause {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block; }
|
||||||
|
.acme-news-ticker-controls button.acme-news-ticker-pause:before {
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-color: #999;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 0 2px 0;
|
||||||
|
-webkit-transform: translate(-50%, -50%);
|
||||||
|
-ms-transform: translate(-50%, -50%);
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
left: 50%;
|
||||||
|
top: 50%; }
|
||||||
|
.acme-news-ticker-controls.acme-news-ticker-horizontal-controls button.acme-news-ticker-prev:after {
|
||||||
|
-webkit-transform: translate(-50%, -50%) rotate(135deg);
|
||||||
|
-ms-transform: translate(-50%, -50%) rotate(135deg);
|
||||||
|
transform: translate(-50%, -50%) rotate(135deg); }
|
||||||
|
.acme-news-ticker-controls.acme-news-ticker-horizontal-controls button.acme-news-ticker-next:after {
|
||||||
|
-webkit-transform: translate(-50%, -50%) rotate(315deg);
|
||||||
|
-ms-transform: translate(-50%, -50%) rotate(315deg);
|
||||||
|
transform: translate(-50%, -50%) rotate(315deg); }
|
||||||
|
.acme-news-ticker-controls.acme-news-ticker-vertical-controls button.acme-news-ticker-prev:after {
|
||||||
|
-webkit-transform: translate(-50%, -50%) rotate(225deg);
|
||||||
|
-ms-transform: translate(-50%, -50%) rotate(225deg);
|
||||||
|
transform: translate(-50%, -50%) rotate(225deg); }
|
||||||
|
.acme-news-ticker-controls.acme-news-ticker-vertical-controls button.acme-news-ticker-next:after {
|
||||||
|
-webkit-transform: translate(-50%, -50%) rotate(405deg);
|
||||||
|
-ms-transform: translate(-50%, -50%) rotate(405deg);
|
||||||
|
transform: translate(-50%, -50%) rotate(405deg); }
|
||||||
|
|
||||||
|
/*# sourceMappingURL=style.css.map */
|
Binary file not shown.
After Width: | Height: | Size: 224 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.7 MiB |
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 57.834 57.955"><defs><style>.a{fill:#f4825c;stroke:#707070;}.b{fill:#e74610;}.c{stroke:none;}.d{fill:none;}</style></defs><g transform="translate(-0.498 0.199)"><g transform="translate(0 0)"><g class="a" transform="translate(1.009 0.934)"><circle class="c" cx="27.989" cy="27.989" r="27.989"/><circle class="d" cx="27.989" cy="27.989" r="27.489"/></g><g transform="translate(-26.502 -27.6)"><g transform="translate(27 27.4)"><path class="b" d="M55.917,85.355A28.978,28.978,0,1,1,84.834,56.317,29.012,29.012,0,0,1,55.917,85.355Zm0-54.31A25.272,25.272,0,1,0,81.189,56.317,25.253,25.253,0,0,0,55.917,31.045Z" transform="translate(-27 -27.4)"/><g transform="translate(18.529 18.65)"><path class="b" d="M59.638,63.344a1.827,1.827,0,0,1-1.337-.486l-8.5-8.5a1.762,1.762,0,0,1,0-2.551l8.5-8.5a1.8,1.8,0,0,1,2.551,2.551l-7.168,7.168,7.168,7.169a1.762,1.762,0,0,1,0,2.551A1.234,1.234,0,0,1,59.638,63.344Z" transform="translate(-40.745 -42.75)"/><path class="b" d="M44.133,63.323a1.827,1.827,0,0,1-1.336-.486,1.762,1.762,0,0,1,0-2.551l7.169-7.169L42.8,45.948A1.8,1.8,0,0,1,45.348,43.4l8.5,8.5a1.762,1.762,0,0,1,0,2.551l-8.5,8.5A1.814,1.814,0,0,1,44.133,63.323Z" transform="translate(-42.25 -42.729)"/></g></g></g></g></g></svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 58.184 58.184"><defs><style>.a{fill:#56b68b;stroke:#707070;}.b{fill:#018952;fill-rule:evenodd;}.c{stroke:none;}.d{fill:none;}</style></defs><g transform="translate(-138.502 -248.613)"><g transform="translate(138.502 248.613)"><g transform="translate(0 0)"><g class="a" transform="translate(1.009 0.934)"><circle class="c" cx="27.989" cy="27.989" r="27.989"/><circle class="d" cx="27.989" cy="27.989" r="27.489"/></g><path class="b" d="M47.664,22.747l2.3,2.3L31.8,43.209l-2.3,2.3-2.3-2.3-8.978-8.978,2.3-2.3L29.5,40.913ZM34.092,5A29.092,29.092,0,1,1,5,34.092,29.079,29.079,0,0,1,34.092,5Zm0,3.967A25.16,25.16,0,1,1,8.967,34.092,25.173,25.173,0,0,1,34.092,8.967Z" transform="translate(-5 -5)"/></g></g></g></svg>
|
After Width: | Height: | Size: 763 B |
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
|
// Determine if the application is in maintenance mode...
|
||||||
|
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
|
||||||
|
require $maintenance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the Composer autoloader...
|
||||||
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
|
// Bootstrap Laravel and handle the request...
|
||||||
|
(require_once __DIR__.'/../bootstrap/app.php')
|
||||||
|
->handleRequest(Request::capture());
|
|
@ -0,0 +1,3 @@
|
||||||
|
import './bootstrap';
|
||||||
|
import axios from 'axios';
|
||||||
|
window.axios = axios; // Make axios globally available
|
|
@ -0,0 +1,4 @@
|
||||||
|
import axios from 'axios';
|
||||||
|
window.axios = axios;
|
||||||
|
|
||||||
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,13 @@
|
||||||
|
$(document).ready(function () {
|
||||||
|
console.log('Sidebar script initialized');
|
||||||
|
$('#sidebarCollapse').on('click', function () {
|
||||||
|
console.log('Sidebar collapse clicked');
|
||||||
|
$('#sidebar').toggleClass('active');
|
||||||
|
$('#content').toggleClass('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.more-button, .body-overlay').on('click', function () {
|
||||||
|
console.log('More button or overlay clicked');
|
||||||
|
$('#sidebar, .body-overlay').toggleClass('show-nav');
|
||||||
|
});
|
||||||
|
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"resources/css/app.css": {
|
||||||
|
"file": "assets/app-BdHssJp-.css",
|
||||||
|
"src": "resources/css/app.css",
|
||||||
|
"isEntry": true
|
||||||
|
},
|
||||||
|
"resources/js/app.js": {
|
||||||
|
"file": "assets/app-Dx9lAnTB.js",
|
||||||
|
"name": "app",
|
||||||
|
"src": "resources/js/app.js",
|
||||||
|
"isEntry": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue