first commit
This commit is contained in:
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@@ -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
|
||||
58
.env.example
Normal file
58
.env.example
Normal file
@@ -0,0 +1,58 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailpit
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=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
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_HOST=
|
||||
PUSHER_PORT=443
|
||||
PUSHER_SCHEME=https
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
* text=auto
|
||||
|
||||
*.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
|
||||
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/.vscode
|
||||
/public
|
||||
/resources
|
||||
/routes
|
||||
/storage
|
||||
/tests
|
||||
|
||||
|
||||
64
.htaccess
Normal file
64
.htaccess
Normal file
@@ -0,0 +1,64 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
# block files which needs to be hidden, specify .example extension of the file
|
||||
<Files ~ "\.(env|env.example|json|config.js|md|gitignore|gitattributes|lock)$">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
</Files>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# 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>
|
||||
|
||||
# BEGIN cPanel-generated php ini directives, do not edit
|
||||
# Manual editing of this file may result in unexpected behavior.
|
||||
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
|
||||
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
|
||||
<IfModule php8_module>
|
||||
php_flag display_errors Off
|
||||
php_value max_execution_time 300
|
||||
php_value max_input_time 120
|
||||
php_value max_input_vars 1000
|
||||
php_value memory_limit 128M
|
||||
php_value post_max_size 16M
|
||||
php_value session.gc_maxlifetime 1440
|
||||
php_value session.save_path "/var/cpanel/php/sessions/ea-php81"
|
||||
php_value upload_max_filesize 10M
|
||||
php_flag zlib.output_compression Off
|
||||
</IfModule>
|
||||
<IfModule lsapi_module>
|
||||
php_flag display_errors Off
|
||||
php_value max_execution_time 300
|
||||
php_value max_input_time 120
|
||||
php_value max_input_vars 1000
|
||||
php_value memory_limit 128M
|
||||
php_value post_max_size 16M
|
||||
php_value session.gc_maxlifetime 1440
|
||||
php_value session.save_path "/var/cpanel/php/sessions/ea-php81"
|
||||
php_value upload_max_filesize 10M
|
||||
php_flag zlib.output_compression Off
|
||||
</IfModule>
|
||||
# END cPanel-generated php ini directives, do not edit
|
||||
|
||||
# php -- BEGIN cPanel-generated handler, do not edit
|
||||
# Set the “ea-php81” package as the default “PHP” programming language.
|
||||
<IfModule mime_module>
|
||||
AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
|
||||
</IfModule>
|
||||
# php -- END cPanel-generated handler, do not edit
|
||||
8
.htaccess_old
Normal file
8
.htaccess_old
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
# php -- BEGIN cPanel-generated handler, do not edit
|
||||
# Set the “ea-php81” package as the default “PHP” programming language.
|
||||
<IfModule mime_module>
|
||||
AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
|
||||
</IfModule>
|
||||
# php -- END cPanel-generated handler, do not edit
|
||||
16
.user.ini
Normal file
16
.user.ini
Normal file
@@ -0,0 +1,16 @@
|
||||
; cPanel-generated php ini directives, do not edit
|
||||
; Manual editing of this file may result in unexpected behavior.
|
||||
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
|
||||
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
|
||||
|
||||
[PHP]
|
||||
display_errors = Off
|
||||
max_execution_time = 300
|
||||
max_input_time = 120
|
||||
max_input_vars = 1000
|
||||
memory_limit = 128M
|
||||
post_max_size = 16M
|
||||
session.gc_maxlifetime = 1440
|
||||
session.save_path = "/var/cpanel/php/sessions/ea-php81"
|
||||
upload_max_filesize = 10M
|
||||
zlib.output_compression = Off
|
||||
66
README.md
Normal file
66
README.md
Normal file
@@ -0,0 +1,66 @@
|
||||
<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 over 2000 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 [Patreon page](https://patreon.com/taylorotwell).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
|
||||
- **[Lendio](https://lendio.com)**
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
44
app/Console/Commands/DeleteNotification.php
Normal file
44
app/Console/Commands/DeleteNotification.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\NotificationUser;
|
||||
|
||||
class DeleteNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'delete:old-notification';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Delete data that was created 3 days ago';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// return Command::SUCCESS;
|
||||
$threeDaysAgo = Carbon::now()->subDays(3);
|
||||
NotificationUser::where('created_at','<',$threeDaysAgo)->delete();
|
||||
|
||||
$this->info('Old notifications deleted successfully.');
|
||||
}
|
||||
}
|
||||
54
app/Console/Commands/MoodOMeterNotification.php
Normal file
54
app/Console/Commands/MoodOMeterNotification.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use App\Models\NotificationUser;
|
||||
use App\Models\NotificationMaster;
|
||||
|
||||
|
||||
class MoodOMeterNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'mood-o-meter:send-daily';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Daily Mood O Meter Reminder';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user = User::get();
|
||||
|
||||
// NotificationMaster::create[]
|
||||
$notification_master = new NotificationMaster;
|
||||
$notification_master->title = "Send Your Daily Mood O Meter";
|
||||
$notification_master->messages = "Mood-O-Meter";
|
||||
$notification_master->save();
|
||||
|
||||
$notification_id = $notification_master->id;
|
||||
|
||||
foreach ($user as $user_data){
|
||||
|
||||
$notification_user = new NotificationUser;
|
||||
$notification_user->notification_id = $notification_id;
|
||||
$notification_user->user_id = $user_data->id;
|
||||
$notification_user->save();
|
||||
}
|
||||
|
||||
$this->info('Mood-O-Meter Notification Send succefully');
|
||||
}
|
||||
}
|
||||
64
app/Console/Commands/PushNotification.php
Normal file
64
app/Console/Commands/PushNotification.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\NotificationUser;
|
||||
use Ladumor\OneSignal\OneSignal;
|
||||
|
||||
class PushNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'send:notification_daily';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send Notification Daily';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$title = "";
|
||||
$messages = [
|
||||
"Open the GSF App and Start Counting Every Step Towards a Fitter You!",
|
||||
"Every step counts on a fitness journey. Open GSF to track yours!",
|
||||
"Open GSF and log your steps to see how you rank on the leaderboard.",
|
||||
"The competition is heating up! Open GSF to track your steps and stay ahead.",
|
||||
"Get moving and conquer your fitness goals! Open GSF to track your steps."
|
||||
];
|
||||
|
||||
$random = array_rand($messages);
|
||||
$message = $messages[$random];
|
||||
// $playerId = "092051ad-e7f3-47c1-b8cf-55db5a4232c3";
|
||||
|
||||
|
||||
$fields = [
|
||||
// 'include_player_ids' => [$playerId],
|
||||
'included_segments'=>[ 'All'],
|
||||
'contents' => ['en' => $message],
|
||||
'headings' => ['en' => $title],
|
||||
'isAndroid'=> true,
|
||||
'content_available' => true,
|
||||
// 'data' => [
|
||||
// 'content_type' => $content_type,
|
||||
// 'id' => $id,
|
||||
// ],
|
||||
// 'big_picture' => $imageUrl,
|
||||
// 'app_id' => env('ONE_SIGNAL_APP_ID'),
|
||||
// 'authorization' => env('ONE_SIGNAL_AUTHORIZE')
|
||||
];
|
||||
|
||||
$result = OneSignal::sendPush($fields);
|
||||
}
|
||||
}
|
||||
37
app/Console/Commands/StepsCountPoint.php
Normal file
37
app/Console/Commands/StepsCountPoint.php
Normal file
@@ -0,0 +1,37 @@
|
||||
// <?php
|
||||
|
||||
// namespace App\Console\Commands;
|
||||
|
||||
// use Illuminate\Console\Command;
|
||||
// use App\Models\DailyStepsCount;
|
||||
// use App\Models\User;
|
||||
// use Carbon\Carbon;
|
||||
// use App\Models\LeaderboardMaster;
|
||||
|
||||
// class StepsCountPoint extends Command
|
||||
// {
|
||||
// protected $signature = 'steps:count';
|
||||
// protected $description = 'Calculate points based on daily step counts.';
|
||||
// public function handle()
|
||||
// {
|
||||
// $date = Carbon::now()->toDateString();
|
||||
// $dailyStepCount = DailyStepsCount::where('date',$date)->get();
|
||||
|
||||
// if($dailyStepCount){
|
||||
// foreach($dailyStepCount as $count){
|
||||
|
||||
// $steps = $count->step_count;
|
||||
// $points = intval(floor($steps/1000));
|
||||
// $user_id = $count->user_id;
|
||||
// $leaderboardMaster = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
// if ($leaderboardMaster) {
|
||||
|
||||
// $leaderboardMaster->total_score += $points;
|
||||
// $leaderboardMaster->save();
|
||||
// }
|
||||
|
||||
// }
|
||||
// $this->info('Points Added Successfully');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
67
app/Console/Commands/StoreMonthlyPositions.php
Normal file
67
app/Console/Commands/StoreMonthlyPositions.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use App\Models\MonthlyPosition;
|
||||
use App\Models\LeaderboardMaster;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class StoreMonthlyPositions extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'positions:store-monthly';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'At the end of the month, the position of every user is stored';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$currentYear = now()->format('Y');
|
||||
// $currentYear = 2023;
|
||||
$currentMonth = now()->format('m');
|
||||
// $currentMonth = 4;
|
||||
$users = User::all();
|
||||
foreach ($users as $user) {
|
||||
$userId = $user->id;
|
||||
$user_list = LeaderboardMaster::orderBy('total_score', 'desc')->get();
|
||||
|
||||
$position = null;
|
||||
|
||||
foreach ($user_list as $index => $user){
|
||||
if($user->user_id == $userId){
|
||||
$position = $index + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($position)) {
|
||||
$monthDate = Carbon::createFromDate($currentYear, $currentMonth, 1)->format('Y-m');
|
||||
|
||||
MonthlyPosition::updateOrCreate([
|
||||
'user_id' => $userId,
|
||||
'month' => $monthDate,
|
||||
], [
|
||||
'position' => $position,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->info('Users Position Stored Successfully!');
|
||||
// return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
35
app/Console/Commands/UpdateTableColumnCommand.php
Normal file
35
app/Console/Commands/UpdateTableColumnCommand.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
|
||||
class UpdateTableColumnCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update:column';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update isactive column value by 1 daily 9AM';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
DB::table('mood_o_meter')->update(['is_active' => '1']);
|
||||
|
||||
$this->info('Table column updated successfully.');
|
||||
}
|
||||
}
|
||||
39
app/Console/Commands/UpdateUserRanking.php
Normal file
39
app/Console/Commands/UpdateUserRanking.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use DB;
|
||||
|
||||
class UpdateUserRanking extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:ranking';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update User Ranking In every Minute';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$schedule->call(function () {
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->get('http://gsf.betadelivery.com/api/getUserRanking');
|
||||
// Handle the API response as needed
|
||||
// $statusCode = $response->getStatusCode();
|
||||
// ...
|
||||
})->everyMinute();
|
||||
}
|
||||
}
|
||||
46
app/Console/Kernel.php
Normal file
46
app/Console/Kernel.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
|
||||
protected $commands = [
|
||||
Commands\UpdateTableColumnCommand::class,
|
||||
Commands\StoreMonthlyPositions::class,
|
||||
Commands\MoodOMeterNotification::class,
|
||||
Commands\DeleteNotification::class,
|
||||
Commands\PushNotification::class,
|
||||
|
||||
];
|
||||
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('update:column')->dailyAt('09:00')->timezone('Asia/Kolkata');
|
||||
$schedule->command('positions:store-monthly')->lastOfMonth('23:59');
|
||||
$schedule->command('mood-o-meter:send-daily')->dailyAt('09:00')->timezone('Asia/Kolkata');
|
||||
$schedule->command('delete:old-notification')->daily();
|
||||
$schedule->command('send:notification_daily')->dailyAt('07:00')->timezone('Asia/Kolkata');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
50
app/Exceptions/Handler.php
Normal file
50
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
74
app/Exports/DataExport.php
Normal file
74
app/Exports/DataExport.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Exports\DataExport;
|
||||
use App\Models\UserOverView;
|
||||
use App\Models\User;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DataExport implements FromCollection, WithHeadings
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$start_date = request()->start_date;
|
||||
// dd($start_date);
|
||||
$end_date = request()->end_date;
|
||||
// dd($end_date);
|
||||
$userData = UserOverView::select('id','user_id','muscle_rate','body_fat','skeletal_muscle', 'protein', 'bmr','water','age','weight','created_at')->with('userData')->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
// dd($userData);
|
||||
if ($userData->isEmpty()) {
|
||||
|
||||
return collect([
|
||||
[
|
||||
'message' => 'No data found for the specified date.',
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
$formattedData = $userData->map(function ($userData, $index) {
|
||||
|
||||
$user_name = isset($userData->userData) && isset($userData->userData)
|
||||
? $userData->userData->full_name : 'N/A';
|
||||
|
||||
return [
|
||||
'id' => $index + 1,
|
||||
'user_id' => $user_name,
|
||||
'Muscle Rate' => $userData->muscle_rate,
|
||||
'Body Fat' => $userData->body_fat,
|
||||
'Skeletal Muscle' => $userData->skeletal_muscle,
|
||||
'Protein' => $userData->protein,
|
||||
'BMR' => $userData->bmr,
|
||||
'Water' => $userData->water,
|
||||
'Age' => $userData->age,
|
||||
'Weight' => $userData->weight,
|
||||
'Date' => Carbon::parse($userData->created_at)->format('Y-m-d'),
|
||||
|
||||
];
|
||||
});
|
||||
|
||||
return $formattedData;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'Name',
|
||||
'Muscle Rate',
|
||||
'Body Fat',
|
||||
'Skeletal Muscle',
|
||||
'Protein',
|
||||
'BMR',
|
||||
'Water',
|
||||
'Age',
|
||||
'Weight',
|
||||
'Date'
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/Exports/UsersExport.php
Normal file
22
app/Exports/UsersExport.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use App\Models\User;
|
||||
|
||||
class UsersExport implements FromCollection
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$userData = User::select('id','full_name','contact_number','email_id')->get();
|
||||
// echo "<pre>"; print_r($userData);
|
||||
// exit;
|
||||
dd($userData);
|
||||
return $userData;
|
||||
|
||||
}
|
||||
}
|
||||
24
app/Http/Controllers/API/AboutController.php
Normal file
24
app/Http/Controllers/API/AboutController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageAboutUs;
|
||||
|
||||
class AboutController extends Controller
|
||||
{
|
||||
|
||||
public function get_About_Us() {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$userid = auth()->user();
|
||||
|
||||
$aboutdata = ManageAboutUs::where($userid)->get();
|
||||
return response([
|
||||
'user' => $aboutdata,
|
||||
// 'token' => $user->createToken('secret')->plainTextToken
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
app/Http/Controllers/API/ContactController.php
Normal file
51
app/Http/Controllers/API/ContactController.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ContactUs;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
|
||||
class ContactController extends Controller {
|
||||
|
||||
public function store_contact_us(Request $req) {
|
||||
try {
|
||||
//
|
||||
$token = readHeaderToken();
|
||||
// print_r($token);exit;
|
||||
if($token){
|
||||
$user = auth()->user();
|
||||
// $bankobj = new ContactUs;
|
||||
// print_r($req->all());
|
||||
// exit;
|
||||
$contactdata = array(
|
||||
'user_id' => $token['sub'],
|
||||
'name' => $req->name,
|
||||
'email_id' => $req->email_id,
|
||||
'contact_number' => $req->contact_number,
|
||||
'subject' => $req->subject,
|
||||
'type' => $req->type,
|
||||
'message' => $req->message,
|
||||
'is_reply' => '0',
|
||||
'is_active' => '1',
|
||||
);
|
||||
|
||||
// print_r($contactdata);
|
||||
// exit;
|
||||
// $userobj = User::find($user);
|
||||
$data = ContactUs::create($contactdata);
|
||||
}
|
||||
return response([
|
||||
'status' => "Success",
|
||||
], 200);
|
||||
// return $data;
|
||||
} catch (Exception $ex) {
|
||||
return response([
|
||||
'status' => "failed",
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateNotificationOneSignalController extends Controller
|
||||
{
|
||||
function createNotification(Request $request) {
|
||||
$player_id = $request->player_id;
|
||||
$heading = $request->heading;
|
||||
$message = $request->content;
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->request('POST', 'https://onesignal.com/api/v1/notifications?app_id=1be4b99b-8faa-45b8-ad82-c66225d77bf4', [
|
||||
'body' => '{"include_player_ids":["'.$player_id.'"],"headings":{"en":"'.$heading.'"},"contents":{"en":"'.$message.'"},"name":"INTERNAL_CAMPAIGN_NAME"}',
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic MWM2NGEyODUtN2U5MS00MzlkLWJhYmItZGUyODRjYTlmNGJm',
|
||||
'accept' => 'application/json',
|
||||
'content-type' => 'application/json',
|
||||
],
|
||||
]);
|
||||
$resBody = $response->getBody();
|
||||
return $resBody;
|
||||
}
|
||||
}
|
||||
68
app/Http/Controllers/API/DietPlanController.php
Normal file
68
app/Http/Controllers/API/DietPlanController.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\DietPlan;
|
||||
use App\Models\UserOverView;
|
||||
|
||||
|
||||
class DietPlanController extends Controller
|
||||
{
|
||||
|
||||
public function get_diet_categories(Request $request)
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$filters = $request->diet_categories;
|
||||
|
||||
// Retrieve the user's bmr from UserOverview table
|
||||
$userOverview = UserOverview::where('user_id', $user_id)
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
// dd($userOverview);
|
||||
$bmr = $userOverview->bmr;
|
||||
$bmrInt = intval($bmr);
|
||||
|
||||
// Retrieve diet plans based on filters and bmr range
|
||||
$query = DietPlan::query();
|
||||
|
||||
// Apply filters
|
||||
if ($filters && in_array($filters, ['Veg', 'Non-Veg'])) {
|
||||
$query->where('diet_categories', '=', $filters);
|
||||
}
|
||||
|
||||
// Apply bmr range filter
|
||||
$query->where('bmr_range_from', '<=', $bmrInt)
|
||||
->where('bmr_range_to', '>=', $bmrInt);
|
||||
|
||||
// Add more filter conditions if needed
|
||||
|
||||
$manage_diet_plan = $query->get()->toArray();
|
||||
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $manage_diet_plan
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Activity data listing failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
24
app/Http/Controllers/API/FaqController.php
Normal file
24
app/Http/Controllers/API/FaqController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageFaq;
|
||||
use Auth;
|
||||
|
||||
class FaqController extends Controller {
|
||||
|
||||
public function get_faq() {
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
|
||||
$faqdata = ManageFaq::with('category')->where('is_active','1')->get();
|
||||
return response([
|
||||
'user' => $faqdata,
|
||||
// 'token' => $user->createToken('secret')->plainTextToken
|
||||
], 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
56
app/Http/Controllers/API/GetAppVersionCotroller.php
Normal file
56
app/Http/Controllers/API/GetAppVersionCotroller.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\AppVersion;
|
||||
class GetAppVersionCotroller extends Controller
|
||||
{
|
||||
public function getOlderVersion(Request $request){
|
||||
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$appOlderVersionAndroi = $request->old_version_android;
|
||||
$appOlderVersionIOS = $request->old_version_ios;
|
||||
|
||||
if($appOlderVersionAndroi){
|
||||
$version = AppVersion::updateOrCreate(['user_id'=>$user_id],['old_version_android'=>$appOlderVersionAndroi]);
|
||||
}else{
|
||||
$version = AppVersion::updateOrCreate(['user_id'=>$user_id],['old_version_ios'=>$appOlderVersionIOS]);
|
||||
}
|
||||
if($version){
|
||||
return response(['status' => "Success"], 200);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getNewVersion(){
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$newVersion = AppVersion::where('user_id',$user_id)->first();
|
||||
return response(['result' => $newVersion,'status'=>"Success",'message'=>"Data Fetch Successfully"]);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAppVersion(Request $request){
|
||||
|
||||
$allData = AppVersion::all();
|
||||
|
||||
$ios = $request->new_version_ios;
|
||||
$android = $request->new_version_android;
|
||||
if($ios){
|
||||
AppVersion::update(['new_version_ios'=>$ios]);
|
||||
}elseif($android){
|
||||
AppVersion::update(['new_version_ios'=>$android]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
730
app/Http/Controllers/API/LeaderBordMasterContoller.php
Normal file
730
app/Http/Controllers/API/LeaderBordMasterContoller.php
Normal file
@@ -0,0 +1,730 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\LeaderboardMaster;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDetail;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Models\MonthlyPosition;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class LeaderBordMasterContoller extends Controller {
|
||||
|
||||
// public function get_user_ranking() {
|
||||
// try {
|
||||
// $token = readHeaderToken();
|
||||
// if ($token) {
|
||||
// $user_id = $token['sub'];
|
||||
//
|
||||
// // Retrieve the user's ranking and related user details
|
||||
// $userRanking = LeaderboardMaster::with('user', 'user_details')
|
||||
// ->get();
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'user_ranking' => $userRanking,
|
||||
// 'message' => 'Data Fetch Successfully!.',
|
||||
// ]);
|
||||
// } else {
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Authentication failed.',
|
||||
// ]);
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// \Log::error("User ranking retrieval failed: " . $e->getMessage());
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Something went wrong.',
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function get_user_ranking($sortOrder = 'desc') {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
|
||||
// Retrieve the user's ranking and related user details
|
||||
$userRanking = LeaderboardMaster::with('user', 'user_data')
|
||||
->orderBy('total_score', $sortOrder)
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'user_ranking' => $userRanking,
|
||||
'message' => 'Data Fetch Successfully!.',
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User ranking retrieval failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_user_gender(Request $request) {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$filters = $request->gender;
|
||||
$query = LeaderboardMaster::with(['user', 'user_data']);
|
||||
|
||||
// Apply filters
|
||||
if ($filters && in_array($filters, ['male', 'female'])) {
|
||||
$query->whereHas('user_data', function ($query) use ($filters) {
|
||||
$query->where('gender', '=', $filters);
|
||||
});
|
||||
}
|
||||
// Add more filter conditions if needed
|
||||
|
||||
$manage_activity = $query->get()->toArray();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $manage_activity
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Activity data listing failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_user_group_level(Request $request) {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$groupLevelFilter = $request->input('group_level');
|
||||
|
||||
$elites = null;
|
||||
$gameChangers = null;
|
||||
$underdogs = null;
|
||||
|
||||
$elites_user_id = [];
|
||||
if ($groupLevelFilter === 'elites') {
|
||||
$elites = GroupLevelElites();
|
||||
// print_r($elites['elites_user_id']);
|
||||
// exit;
|
||||
} elseif ($groupLevelFilter === 'gameChangers') {
|
||||
|
||||
$gameChangers = GroupLevelGameChanger();
|
||||
} elseif ($groupLevelFilter === 'underdogs') {
|
||||
$underdogs_user_id = [];
|
||||
$game_changer_data = GroupLevelGameChanger();
|
||||
$users_id = $game_changer_data['all_top_users_id'];
|
||||
$underdog = LeaderboardMaster::whereNotIn('user_id', $users_id)->orderBy('total_score', 'desc')->get();
|
||||
foreach ($underdog as $k => $val){
|
||||
$underdogs_user_id[] = $val->user_id;
|
||||
}
|
||||
// dd($underdogs_user_id);
|
||||
|
||||
$underdogs['underdogs'] = $underdog;
|
||||
$underdogs['underdogs_user_id'] = $underdogs_user_id;
|
||||
} else {
|
||||
// Invalid group level filter
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid group level filter.',
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'elites' => $elites,
|
||||
'gameChangers' => $gameChangers,
|
||||
'underdogs' => $underdogs,
|
||||
];
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Activity data listing failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// public function filter_users(Request $request) {
|
||||
// try {
|
||||
// $token = readHeaderToken();
|
||||
// if ($token) {
|
||||
// $user_id = $token['sub'];
|
||||
//
|
||||
// $filters = $request->input('gender');
|
||||
// $groupLevelFilter = $request->input('group_level');
|
||||
//
|
||||
// $query = LeaderboardMaster::with(['user', 'user_data']);
|
||||
//
|
||||
// // Apply gender filter
|
||||
// if ($filters && in_array($filters, ['male', 'female'])) {
|
||||
// $query->whereHas('user_data', function ($query) use ($filters) {
|
||||
// $query->where('gender', '=', $filters);
|
||||
// });
|
||||
// } elseif ($filters !== null) {
|
||||
// // Invalid gender filter
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Invalid gender filter.',
|
||||
// ]);
|
||||
// }
|
||||
// // Apply group level filter
|
||||
// $elites = null;
|
||||
// $gameChangers = null;
|
||||
// $underdogs = null;
|
||||
// $elites_user_id = [];
|
||||
//
|
||||
// if ($groupLevelFilter === 'elites') {
|
||||
// $elites = GroupLevelElites();
|
||||
//
|
||||
// // Filter by gender
|
||||
// if ($filters && in_array($filters, ['male', 'female'])) {
|
||||
// $elites = array_filter($elites, function ($elite) use ($filters) {
|
||||
// return $elite['gender'] === $filters;
|
||||
// });
|
||||
// }
|
||||
// } elseif ($groupLevelFilter === 'gameChangers') {
|
||||
// $gameChangers = GroupLevelGameChanger();
|
||||
//
|
||||
// // Filter by gender
|
||||
// if ($filters && in_array($filters, ['male', 'female'])) {
|
||||
// $gameChangers = array_filter($gameChangers, function ($gameChanger) use ($filters) {
|
||||
// return $gameChanger['gender'] === $filters;
|
||||
// });
|
||||
// }
|
||||
// } elseif ($groupLevelFilter === 'underdogs') {
|
||||
// $game_changer_data = GroupLevelGameChanger();
|
||||
// $users_id = $game_changer_data['all_top_users_id'];
|
||||
// $query->whereNotIn('user_id', $users_id)->orderBy('total_score', 'desc');
|
||||
//
|
||||
// // Apply gender filter
|
||||
//if ($filters && in_array($filters, ['male', 'female'])) {
|
||||
// $query->whereHas('user_data', function ($query) use ($filters) {
|
||||
// $query->where('gender', '=', $filters);
|
||||
// });
|
||||
//} elseif ($filters !== null) {
|
||||
// // Invalid gender filter
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Invalid gender filter.',
|
||||
// ]);
|
||||
//}
|
||||
//
|
||||
// $users = $query->get()->toArray();
|
||||
//
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'message' => 'Data fetched successfully.',
|
||||
// 'result' => [
|
||||
// 'users' => $users,
|
||||
// 'elites' => $elites,
|
||||
// 'gameChangers' => $gameChangers,
|
||||
// 'underdogs' => $underdogs,
|
||||
// ],
|
||||
// ]);
|
||||
// } else {
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Authentication failed.',
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// }catch (\Exception $e) {
|
||||
// \Log::error("User filtering failed: " . $e->getMessage());
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Something went wrong.',
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function get_user_data(Request $request)
|
||||
{
|
||||
try {
|
||||
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
//get user data for check gender and group level
|
||||
$user = User::with('user_detail')->find($user_id);
|
||||
|
||||
//request inputs
|
||||
$sortOrder = $request->input('sort_order');
|
||||
$gender = "all";
|
||||
|
||||
// if($gender != "all"){
|
||||
// $gender = $request->input('gender');
|
||||
// }
|
||||
// else{
|
||||
// $gender = "all";
|
||||
// }
|
||||
$groupLevelFilter = $request->input('group_level');
|
||||
|
||||
// Retrieve the user's ranking and related user details
|
||||
$query = LeaderboardMaster::with('user', 'user_data','user.stepCount');
|
||||
|
||||
// for gender
|
||||
// $gender = "all";
|
||||
if($request->has('gender')){
|
||||
$gender = $request->input('gender');
|
||||
// Apply gender filter
|
||||
if ($gender != "all") {
|
||||
$query->whereHas('user_data', function ($query) use ($gender) {
|
||||
$query->where('gender', '=', $gender);
|
||||
});
|
||||
}
|
||||
}
|
||||
// else{
|
||||
|
||||
// $gender = $user->user_detail->gender;
|
||||
// if($gender){
|
||||
// if ($gender && in_array($gender, ['male', 'female'])) {
|
||||
// $query->whereHas('user_data', function ($query) use ($gender) {
|
||||
// $query->where('gender', '=', $gender);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//for group level
|
||||
$elite = GroupLevelElites();
|
||||
$game_changer = GroupLevelGameChanger();
|
||||
$flattenedEliteArray = Arr::flatten($elite['elites_user_id']);
|
||||
$flattenedGameChangerArray = Arr::flatten($game_changer['all_top_users_id']);
|
||||
$filteredGameChangerArray = array_diff($flattenedGameChangerArray, $flattenedEliteArray);
|
||||
|
||||
if($request->has('group_level')){
|
||||
if ($groupLevelFilter === 'elites') {
|
||||
// Apply elites filter
|
||||
$group_level = "elites";
|
||||
$query->whereIn('user_id', $flattenedEliteArray);
|
||||
} elseif ($groupLevelFilter === 'gameChangers') {
|
||||
// Apply gameChangers filter
|
||||
$group_level = "gameChangers";
|
||||
$query->whereIn('user_id', $filteredGameChangerArray);
|
||||
} elseif ($groupLevelFilter === 'underdogs') {
|
||||
// Apply underdogs filter
|
||||
$group_level = "underdogs";
|
||||
$query->whereNotIn('user_id', $flattenedGameChangerArray);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid group level filter.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (in_array($user_id, $flattenedEliteArray)) {
|
||||
$group_level = "elites";
|
||||
$query->whereIn('user_id', $flattenedEliteArray);
|
||||
} elseif (in_array($user_id, $filteredGameChangerArray)) {
|
||||
$group_level = "gameChangers";
|
||||
$query->whereIn('user_id', $filteredGameChangerArray);
|
||||
} else {
|
||||
$group_level = "underdogs";
|
||||
$query->whereNotIn('user_id', $flattenedGameChangerArray);
|
||||
}
|
||||
}
|
||||
// Apply sorting
|
||||
if ($sortOrder === 'asc') {
|
||||
$query->orderBy('total_score', 'asc');
|
||||
} else {
|
||||
$query->orderBy('total_score', 'desc');
|
||||
}
|
||||
//final query
|
||||
$user_data = $query->get()->toArray();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
// 'user_data' => $user_data,
|
||||
'message' => 'Data Fetch Successfully!.',
|
||||
'user_data' => $user_data,
|
||||
'gender' => $gender,
|
||||
'group_level' => $group_level
|
||||
]);
|
||||
|
||||
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Data retrieval failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get_user_data_home(Request $request)
|
||||
{
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
//get user data for check gender and group level
|
||||
$user = User::with('user_detail')->find($user_id);
|
||||
|
||||
//request inputs
|
||||
$sortOrder = $request->input('sort_order');
|
||||
$gender = "all";
|
||||
|
||||
// if($gender != "all"){
|
||||
// $gender = $request->input('gender');
|
||||
// }
|
||||
// else{
|
||||
// $gender = "all";
|
||||
// }
|
||||
$groupLevelFilter = $request->input('group_level');
|
||||
|
||||
// Retrieve the user's ranking and related user details
|
||||
$query = LeaderboardMaster::with('user', 'user_data');
|
||||
|
||||
// for gender
|
||||
// $gender = "all";
|
||||
if($request->has('gender')){
|
||||
$gender = $request->input('gender');
|
||||
// Apply gender filter
|
||||
if ($gender != "all") {
|
||||
$query->whereHas('user_data', function ($query) use ($gender) {
|
||||
$query->where('gender', '=', $gender);
|
||||
});
|
||||
}
|
||||
}
|
||||
// else{
|
||||
|
||||
// $gender = $user->user_detail->gender;
|
||||
// if($gender){
|
||||
// if ($gender && in_array($gender, ['male', 'female'])) {
|
||||
// $query->whereHas('user_data', function ($query) use ($gender) {
|
||||
// $query->where('gender', '=', $gender);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//for group level
|
||||
$elite = GroupLevelElites();
|
||||
$game_changer = GroupLevelGameChanger();
|
||||
$flattenedEliteArray = Arr::flatten($elite['elites_user_id']);
|
||||
$flattenedGameChangerArray = Arr::flatten($game_changer['all_top_users_id']);
|
||||
$filteredGameChangerArray = array_diff($flattenedGameChangerArray, $flattenedEliteArray);
|
||||
|
||||
if($request->has('group_level')){
|
||||
if ($groupLevelFilter === 'elites') {
|
||||
// Apply elites filter
|
||||
$group_level = "elites";
|
||||
$query->whereIn('user_id', $flattenedEliteArray);
|
||||
} elseif ($groupLevelFilter === 'gameChangers') {
|
||||
// Apply gameChangers filter
|
||||
$group_level = "gameChangers";
|
||||
$query->whereIn('user_id', $filteredGameChangerArray);
|
||||
} elseif ($groupLevelFilter === 'underdogs') {
|
||||
// Apply underdogs filter
|
||||
$group_level = "underdogs";
|
||||
$query->whereNotIn('user_id', $flattenedGameChangerArray);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid group level filter.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (in_array($user_id, $flattenedEliteArray)) {
|
||||
$group_level = "elites";
|
||||
$query->whereIn('user_id', $flattenedEliteArray);
|
||||
} elseif (in_array($user_id, $filteredGameChangerArray)) {
|
||||
$group_level = "gameChangers";
|
||||
$query->whereIn('user_id', $filteredGameChangerArray);
|
||||
} else {
|
||||
$group_level = "underdogs";
|
||||
$query->whereNotIn('user_id', $flattenedGameChangerArray);
|
||||
}
|
||||
}
|
||||
// Apply sorting
|
||||
if ($sortOrder === 'asc') {
|
||||
$query->orderBy('total_score', 'asc');
|
||||
} else {
|
||||
$query->orderBy('total_score', 'desc');
|
||||
}
|
||||
//final query
|
||||
$user_data = $query->get()->toArray();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
// 'user_data' => $user_data,
|
||||
'message' => 'Data Fetch Successfully!.',
|
||||
'user_data' => $user_data,
|
||||
'gender' => $gender,
|
||||
'group_level' => $group_level
|
||||
]);
|
||||
|
||||
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Data retrieval failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function ranking_position(){
|
||||
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
|
||||
$currentYear = now()->format('Y');
|
||||
// $currentYear = 2023;
|
||||
$currentMonth = Carbon::now()->format('m');
|
||||
// $currentMonth = 9;
|
||||
|
||||
|
||||
$users = User::where('status','1')->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$userId = $user->id;
|
||||
$user = User::with('user_detail')->find($userId);
|
||||
$query = LeaderboardMaster::with('user', 'user_data');
|
||||
|
||||
//get gender
|
||||
// $gender = $user->user_detail->gender ;
|
||||
// if ($gender && in_array($gender, ['male', 'female'])) {
|
||||
// $query->whereHas('user_data', function ($query) use ($gender) {
|
||||
// $query->where('gender', '=', $gender);
|
||||
// });
|
||||
// }
|
||||
//for group level
|
||||
$elite = GroupLevelElites();
|
||||
$game_changer = GroupLevelGameChanger();
|
||||
$flattenedEliteArray = Arr::flatten($elite['elites_user_id']);
|
||||
$flattenedGameChangerArray = Arr::flatten($game_changer['all_top_users_id']);
|
||||
$filteredGameChangerArray = array_diff($flattenedGameChangerArray, $flattenedEliteArray);
|
||||
|
||||
if (in_array($userId, $flattenedEliteArray)) {
|
||||
$group_level = 1;
|
||||
$query->whereIn('user_id', $flattenedEliteArray);
|
||||
$user_list = $query->orderBy('total_score', 'desc')->get();
|
||||
} elseif (in_array($userId, $filteredGameChangerArray)) {
|
||||
$group_level = 2;
|
||||
$query->whereIn('user_id', $filteredGameChangerArray);
|
||||
$user_list = $query->orderBy('total_score', 'desc')->get();
|
||||
} else {
|
||||
$group_level = 3;
|
||||
$query->whereNotIn('user_id', $flattenedGameChangerArray);
|
||||
$user_list = $query->orderBy('total_score', 'desc')->get();
|
||||
}
|
||||
|
||||
$position = null;
|
||||
|
||||
foreach ($user_list as $index => $user){
|
||||
if($user->user_id == $userId){
|
||||
$position = $index + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$existingPositionRecord = MonthlyPosition::where([
|
||||
'user_id' => $userId,
|
||||
'month' => Carbon::createFromDate($currentYear, $currentMonth, 1)->format('Y-m'),
|
||||
])->first();
|
||||
|
||||
if ($existingPositionRecord){
|
||||
if($existingPositionRecord->group_level >= $group_level){
|
||||
if($position < $existingPositionRecord->position || $group_level != $existingPositionRecord->group_level) {
|
||||
$monthDate = Carbon::createFromDate($currentYear, $currentMonth, 1)->format('Y-m');
|
||||
|
||||
MonthlyPosition::updateOrCreate([
|
||||
'user_id' => $userId,
|
||||
'month' => $monthDate,
|
||||
'position' => $position,
|
||||
'group_levels' => $group_level,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$monthDate = Carbon::createFromDate($currentYear, $currentMonth, 1)->format('Y-m');
|
||||
|
||||
MonthlyPosition::updateOrCreate([
|
||||
'user_id' => $userId,
|
||||
'month' => $monthDate,
|
||||
'position' => $position,
|
||||
'group_levels' => $group_level,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
|
||||
'success' => true,
|
||||
'message' => 'Position Stored Successfully!.',
|
||||
]);
|
||||
} catch (Exception $ex) {
|
||||
\Log::error("Data retrieval failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_user_position(){
|
||||
|
||||
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$currentYear = now()->format('Y');
|
||||
$yearStartDate = Carbon::createFromDate($currentYear, 1, 1)->format('Y-m-d');
|
||||
$yearEndDate = Carbon::createFromDate($currentYear, 12, 31)->format('Y-m-d');
|
||||
|
||||
// Get all the data for the user for the entire current year
|
||||
$user_monthly_positions = MonthlyPosition::whereBetween('month', [$yearStartDate, $yearEndDate])
|
||||
->where('user_id', $user_id)
|
||||
->orderBy('month', 'asc')
|
||||
->get();
|
||||
|
||||
// Create empty records for missing months
|
||||
$allMonths = collect([]);
|
||||
$currentMonthDate = Carbon::createFromDate($currentYear, 1, 1);
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$allMonths->push($currentMonthDate->format('Y-m'));
|
||||
$currentMonthDate->addMonth();
|
||||
}
|
||||
|
||||
// Merge empty records for missing months into the original collection
|
||||
$user_monthly_positions = $allMonths->map(function ($month) use ($user_monthly_positions, $user_id) {
|
||||
return $user_monthly_positions->firstWhere('month', $month) ?? new MonthlyPosition([
|
||||
'user_id' => $user_id,
|
||||
'month' => $month,
|
||||
'position' => null, // You can set a default value for the position here
|
||||
]);
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data Fetch Successfully',
|
||||
'monthly_positions' => $user_monthly_positions,
|
||||
]);
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
\Log::error("Data retrieval failed: " . $ex->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_daily_user_position(){
|
||||
|
||||
try {
|
||||
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
|
||||
$userId = $token['sub'];
|
||||
$user = User::with('user_detail')->find($userId);
|
||||
// $user_list = LeaderboardMaster::orderBy('total_score', 'desc')->get();
|
||||
$query = LeaderboardMaster::with('user', 'user_data');
|
||||
//get gender
|
||||
// $gender = $user->user_detail->gender;
|
||||
// if($gender){
|
||||
// if ($gender && in_array($gender, ['male', 'female'])) {
|
||||
// $query->whereHas('user_data', function ($query) use ($gender) {
|
||||
// $query->where('gender', '=', $gender);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//for group level
|
||||
$elite = GroupLevelElites();
|
||||
$game_changer = GroupLevelGameChanger();
|
||||
$flattenedEliteArray = Arr::flatten($elite['elites_user_id']);
|
||||
$flattenedGameChangerArray = Arr::flatten($game_changer['all_top_users_id']);
|
||||
$filteredGameChangerArray = array_diff($flattenedGameChangerArray, $flattenedEliteArray);
|
||||
|
||||
if (in_array($userId, $flattenedEliteArray)) {
|
||||
$group_level = "elites";
|
||||
$query->whereIn('user_id', $flattenedEliteArray);
|
||||
} elseif (in_array($userId, $filteredGameChangerArray)) {
|
||||
$group_level = "gameChangers";
|
||||
$query->whereIn('user_id', $filteredGameChangerArray);
|
||||
} else {
|
||||
$group_level = "underdogs";
|
||||
$query->whereNotIn('user_id', $flattenedGameChangerArray);
|
||||
}
|
||||
|
||||
//final query
|
||||
$user_list = $query->orderBy('total_score', 'desc')->get();
|
||||
$position = null;
|
||||
|
||||
foreach ($user_list as $index => $user){
|
||||
if($user->user_id == $userId){
|
||||
$position = $index + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
|
||||
'success' => true,
|
||||
'message' => 'Data Fetch Successfully',
|
||||
'daily_position' => $position,
|
||||
|
||||
]);
|
||||
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
|
||||
} catch (Exception $ex) {
|
||||
\Log::error("Data retrieval failed: " . $ex->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
326
app/Http/Controllers/API/LoginController.php
Normal file
326
app/Http/Controllers/API/LoginController.php
Normal file
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Models\UserEmailOtp;
|
||||
use App\Models\UserDetail;
|
||||
use Carbon\Carbon;
|
||||
use Auth;
|
||||
// use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Validator;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\SendUserOtp;
|
||||
use App\Models\mood_o_meter;
|
||||
use App\Models\PersonalAccessToken;
|
||||
use App\Models\LeaderboardMaster;
|
||||
|
||||
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(),[
|
||||
'email_id' => 'required|email',
|
||||
'password' => 'required|string|min:6'
|
||||
]);
|
||||
|
||||
$credentials = $request->only('email_id', 'password');
|
||||
$token = Auth::guard('api')->attempt($credentials);
|
||||
// $token = auth('api')->attempt($credentials);
|
||||
// dd("TOKEN",$token);
|
||||
if (!$token) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Wrong Creditials',
|
||||
'status'=>401,
|
||||
], 401);
|
||||
}
|
||||
|
||||
$user = Auth::guard('api')->user();
|
||||
|
||||
// dd($user->end_date);
|
||||
$todays_date = Carbon::now()->toDateString();
|
||||
// dd($todays_date);
|
||||
$endDate = Carbon::parse($user->end_date);
|
||||
$subscriptionEndsIn7Days = $endDate->addDays(7)->toDateString();
|
||||
if($subscriptionEndsIn7Days == null || $subscriptionEndsIn7Days < $todays_date){
|
||||
$logout = auth('api')->logout();
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Subscription end',
|
||||
'status'=>201,], 201);
|
||||
}
|
||||
|
||||
$personalAccessToken = new PersonalAccessToken();
|
||||
$personalAccessToken->user_id = $user->id;
|
||||
$personalAccessToken->token = $token;
|
||||
$personalAccessToken->last_login = Carbon::now()->format('Y-m-d H:i:s');
|
||||
$personalAccessToken->save();
|
||||
|
||||
//moodometer add data
|
||||
$existingRecord = mood_o_meter::where('user_id', $user->id)->exists();
|
||||
if (!$existingRecord) {
|
||||
// Create a new mood record
|
||||
$newEntry = mood_o_meter::create([
|
||||
'user_id' => $user->id,
|
||||
'mood_o_meter' => null,
|
||||
'is_active' => '1',
|
||||
]);
|
||||
}
|
||||
|
||||
//Leaderboard add data
|
||||
$existingRecord = LeaderboardMaster::where('user_id', $user->id)->exists();
|
||||
if (!$existingRecord) {
|
||||
// Create a new leaderbaord record
|
||||
$newEntry = LeaderboardMaster::create([
|
||||
'user_id' => $user->id,
|
||||
'total_score' => '0',
|
||||
'progress_bar' => '0',
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
$user = User::with('user_detail')->where('id', $user->id)->first()->toArray();
|
||||
// $user = User::select('id','full_name','contact_number','email_id','status')->where('id',$user->id)->first()->toArray();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => true,
|
||||
'message'=> 'You are successfully logged in',
|
||||
'authorisation' => [
|
||||
'token' => $token,
|
||||
'user_data' => $user,
|
||||
'type' => 'bearer',
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function update_password(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
// 'current_password' => 'required|string|min:6',
|
||||
'password' => 'required|string|confirmed'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'status' => 406,
|
||||
'message' => 'Password does not match',
|
||||
'error' => $validator->errors(),
|
||||
], 401);
|
||||
}
|
||||
|
||||
# Match The Old Password
|
||||
|
||||
$user = User::where('id', $request->user_id)->first();
|
||||
$user->password = Hash::make($request->input('password'));
|
||||
$user->update();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
'message' => 'Password changed successfully!',
|
||||
]);
|
||||
}
|
||||
|
||||
public function generate(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email_id' => 'required|email',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors()], 401);
|
||||
}
|
||||
//check user exist or not
|
||||
$email = $request->email_id;
|
||||
$user = User::where('email_id', $email)->first();
|
||||
|
||||
if(!$user){
|
||||
return response(["status" => 404,
|
||||
'message' => 'Email Id Does Not Exist']
|
||||
);
|
||||
}
|
||||
// Generate An Otp
|
||||
$otp = UserEmailOtp::updateOrCreate(['user_id' => $user->id],
|
||||
[ 'otp' => rand(1000, 9999),
|
||||
'valid_upto' => Carbon::now()->addMinutes(10)
|
||||
]);
|
||||
|
||||
if ($otp) {
|
||||
// send otp in the email
|
||||
$mail_details = [
|
||||
'email' => $request->email_id,
|
||||
'subject' => 'Forgot Password',
|
||||
'body' => 'Your OTP is : ' . $otp->otp
|
||||
];
|
||||
|
||||
$mail = \Mail::to($request->email_id)->send(new SendUserOtp($mail_details));
|
||||
|
||||
return response(["status" => 200,
|
||||
"message" => "OTP sent successfully",
|
||||
'user_id' => $otp['user_id']]);
|
||||
} else {
|
||||
return response(["status" => 401,
|
||||
'message' => 'Invalid']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function verifyOtp(Request $request) {
|
||||
|
||||
$emailId = $request->email_id;
|
||||
$otp = $request->otp;
|
||||
// dd($emailId,$otp);
|
||||
$user = User::where('email_id', $emailId)->first();
|
||||
$varificationCode = UserEmailOtp::where('user_id', $user->id)->latest()->first();
|
||||
// dd($varificationCode);
|
||||
$now = Carbon::now();
|
||||
|
||||
if ($varificationCode && $now->isAfter($varificationCode->valid_upto)) {
|
||||
return response()->json([
|
||||
'status' => 500,
|
||||
'message' => 'Your OTP has been expired',
|
||||
], 500);
|
||||
}
|
||||
if($varificationCode->otp != $otp){
|
||||
return response(["status" => 401,
|
||||
'message' => 'Invalid OTP']
|
||||
);
|
||||
}else{
|
||||
return response(["status" => 200,
|
||||
'message' => 'Valid OTP']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function create_new_pass_with_otp(Request $request) {
|
||||
$request->validate([
|
||||
'user_id' => 'required|exists:users,id',
|
||||
]);
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'otp' => 'required'
|
||||
]);
|
||||
|
||||
#Validation Logic
|
||||
$verificationCode = UserEmailOtp::where('user_id', $request->user_id)
|
||||
->where('otp', $request->otp)
|
||||
->first();
|
||||
|
||||
$now = Carbon::now();
|
||||
if (!$verificationCode) {
|
||||
return response()->json([
|
||||
'status' => 401,
|
||||
'message' => 'Invalid',
|
||||
], 401);
|
||||
} elseif ($verificationCode && $now->isAfter($verificationCode->valid_upto)) {
|
||||
return response()->json([
|
||||
'status' => 500,
|
||||
'message' => 'Your OTP has been expired',
|
||||
], 500);
|
||||
} else {
|
||||
return response()->json([
|
||||
'status' => 200,
|
||||
'message' => 'Otp Verify successfully',
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function resend_otp(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email_id' => 'required|email',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors()], 401);
|
||||
}
|
||||
|
||||
// Generate An Otp
|
||||
$email = $request->email_id;
|
||||
$user = User::where('email_id', $email)->first();
|
||||
$otp = UserEmailOtp::updateOrCreate(['user_id' => $user->id],
|
||||
[ 'otp' => rand(1000, 9999),
|
||||
'valid_upto' => Carbon::now()->addMinutes(10)
|
||||
]);
|
||||
|
||||
if ($otp) {
|
||||
// send otp in the email
|
||||
$mail_details = [
|
||||
'email' => $request->email_id,
|
||||
'subject' => 'Forgot Password',
|
||||
'body' => 'Your OTP is : ' . $otp->otp
|
||||
];
|
||||
// print_r($mail_details);exit;
|
||||
|
||||
\Mail::to($request->email_id)->send(new SendUserOtp($mail_details));
|
||||
|
||||
return response(["status" => 200,
|
||||
"message" => "OTP sent successfully",
|
||||
'user_id' => $otp['user_id']]);
|
||||
} else {
|
||||
return response(["status" => 401,
|
||||
'message' => 'Invalid']
|
||||
);
|
||||
}
|
||||
|
||||
// $message = "Your otp is - ".$varificationCode->otp;
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
'message' => $message,
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetPassword(Request $request){
|
||||
|
||||
$userId = $request->user_id;
|
||||
$oldPass = $request->old_pass;
|
||||
$newPass = $request->new_pass;
|
||||
|
||||
//check old password is not match with new password
|
||||
|
||||
$userPass = User::where('id',$userId)->first();
|
||||
|
||||
if(!Hash::check($oldPass,$userPass->password)){
|
||||
|
||||
return response()->json([
|
||||
'status'=>201 ,
|
||||
'message'=>'Wrong Password'
|
||||
]);
|
||||
}elseif(Hash::check($newPass,$userPass->password)){
|
||||
return response()->json([
|
||||
'status'=>201 ,
|
||||
'message'=>'New Password and Old Password Cannot Be same'
|
||||
]);
|
||||
|
||||
}else{
|
||||
$user = User::where('id', $userId)->first();
|
||||
$user->password = Hash::make($newPass);
|
||||
$user->update();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
'message' => 'Password changed successfully!',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
544
app/Http/Controllers/API/ManageActivityController.php
Normal file
544
app/Http/Controllers/API/ManageActivityController.php
Normal file
@@ -0,0 +1,544 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ActivityMaster;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use App\Models\ActivitySchedule;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\ManageFaq;
|
||||
use App\Models\PastSession;
|
||||
use App\Models\LeaderboardMaster;
|
||||
use App\Models\UserContentView;
|
||||
use App\Models\LinkFaqActivityMasterIds;
|
||||
use App\Models\ActivityDay;
|
||||
use App\Models\User;
|
||||
use Validator;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Torann\GeoIP\Facades\GeoIP;
|
||||
use Spatie\TimeZone\GoogleTimeZone;
|
||||
|
||||
use App\Helpers\Webhelper;
|
||||
|
||||
|
||||
|
||||
class ManageActivityController extends Controller {
|
||||
|
||||
public function get_manage_activity_id() {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$activityId = request('activityId');
|
||||
|
||||
$activity = ActivityMaster::with('subscription', 'schedule')->with('faq_activity_link.faqsData')->find($activityId);
|
||||
|
||||
if ($activity) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Activity fetched successfully.',
|
||||
'result' => $activity
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Activity not found.',
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Activity data listing failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_manage_activity(Request $request) {
|
||||
// try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
// dd($user_id);
|
||||
|
||||
$user_data = User::where('id',$user_id)->first();
|
||||
$utm_source = $user_data->utm_source;
|
||||
$subscription_data = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
// dd($utm_source);
|
||||
$subscription_id = $subscription_data->id;
|
||||
// dd($subscription_id);
|
||||
$current_day = Carbon::now()->toDateString();
|
||||
// dd($current_day);
|
||||
$manage_activity = ActivityDay::where('date', '=', $current_day)
|
||||
// ->where('')
|
||||
->where('subscription_id', $subscription_id)
|
||||
->with('subscription')
|
||||
->with('faq_activity_link.faqsData')
|
||||
->with('scheduleData', 'activityData.subscription')
|
||||
->with('activityData.teacher_data')
|
||||
->get();
|
||||
// dd($manage_activity);
|
||||
$userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// Make a GET request to ipinfo.io
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// Parse the JSON response
|
||||
|
||||
$ch = curl_init("https://ipinfo.io/{$userIP}/json");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$locationData = json_decode($response);
|
||||
|
||||
// Extract the user's time zone from the location data
|
||||
$userTimeZone = $locationData->timezone;
|
||||
// dd($userTimeZone);
|
||||
// Convert the time to the user's time zone
|
||||
// $userTimeZone = $ca$carbonTimetz($userTimeZone);
|
||||
$manage_activity->each(function ($item) {
|
||||
$timestamp = $item->time;
|
||||
$normalTime = Carbon::createFromFormat('H:i', $timestamp, 'Asia/Kolkata'); // Replace 'your_timezone' with the actual timezone of the 'time' column
|
||||
$utcTime = $normalTime->utc();
|
||||
$item->time = $utcTime->format('H:i'); // Update the 'time' value with the UTC time in 'HH:mm' format
|
||||
return $item;
|
||||
});
|
||||
$result = $manage_activity;
|
||||
// $userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// // Make a GET request to ipinfo.io
|
||||
// $response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// // Parse the JSON response
|
||||
// $locationData = $response->json();
|
||||
|
||||
// // Extract the user's time zone from the location data
|
||||
// $userTimeZone = $locationData['timezone'];
|
||||
|
||||
// $manage_activity->each(function ($item) use ($userTimeZone) {
|
||||
// $timestamp = $item->time;
|
||||
// $normalTime = Carbon::createFromFormat('H:i', $timestamp, $userTimeZone); // Replace 'your_timezone' with the actual timezone of the 'time' column
|
||||
// $normalTime->setTimezone($userTimeZone); // Convert to the user's time zone
|
||||
// $item->time = $normalTime->format('H:i'); // Update the 'time' value with the user's time zone in 'HH:mm' format
|
||||
// return $item;
|
||||
// });
|
||||
|
||||
// $result = $manage_activity;
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $result
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get_manage_activity_schedule() {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$user_data = User::where('id',$user_id)->first();
|
||||
$utm_source = $user_data->utm_source;
|
||||
|
||||
$subscription_data = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
// dd($subscription_data);
|
||||
$subscription_id = $subscription_data->id;
|
||||
$current_day = Carbon::now()->toDateString();
|
||||
$activity_schedule = ActivityDay::where('date', '>', $current_day)
|
||||
->where('subscription_id', $subscription_id)
|
||||
->with('subscription')
|
||||
->with('scheduleData', 'activityData.teacher_data')
|
||||
->orderBy('date', 'asc')
|
||||
->get();
|
||||
|
||||
$activity_schedule->each(function ($item) {
|
||||
$timestamp = $item->time;
|
||||
$normalTime = Carbon::createFromFormat('H:i', $timestamp, 'Asia/Kolkata'); // Replace 'your_timezone' with the actual timezone of the 'time' column
|
||||
$utcTime = $normalTime->utc();
|
||||
$item->time = $utcTime->format('H:i'); // Update the 'time' value with the UTC time in 'HH:mm' format
|
||||
return $item;
|
||||
});
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $activity_schedule
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_manage_activity_schedule_utc() {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$user_data = User::where('id',$user_id)->first();
|
||||
$utm_source = $user_data->utm_source;
|
||||
|
||||
$subscription_data = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
$subscription_id = $subscription_data->id;
|
||||
$current_day = Carbon::now()->toDateString();
|
||||
$activity_schedule = ActivityDay::where('date', '>', $current_day)
|
||||
->where('subscription_id', $subscription_id)
|
||||
->with('subscription')
|
||||
->with('scheduleData', 'activityData.teacher_data')
|
||||
->get();
|
||||
$activity_schedule->each(function ($item) {
|
||||
$timestamp = $item->time;
|
||||
$normalTime = Carbon::createFromFormat('H:i', $timestamp, 'Asia/Kolkata'); // Replace 'your_timezone' with the actual timezone of the 'time' column
|
||||
$utcTime = $normalTime->utc();
|
||||
$item->time = $utcTime->format('H:i'); // Update the 'time' value with the UTC time in 'HH:mm' format
|
||||
return $item;
|
||||
});
|
||||
// $activity_schedule_array = $activity_schedule->toArray();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $activity_schedule
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function get_schedule_id() {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$scheduleId = request('scheduleId');
|
||||
// $data = User::with('user_details')->where('id', $user_id)->first()->toArray();
|
||||
|
||||
$activity_schedule = ActivitySchedule::with('subscription')->find($scheduleId);
|
||||
|
||||
// print_r($activity_schedule);exit;
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $activity_schedule
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_manage_past_session() {
|
||||
// try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$user_data = User::where('id',$user_id)->first();
|
||||
// dd($user_data);
|
||||
$utm_source = $user_data->utm_source;
|
||||
// dd($utm_source);
|
||||
|
||||
$subscription_data = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
$subscription_id = $subscription_data->id;
|
||||
// dd($subscription_id);
|
||||
$activity_data = ActivityMaster::where('subscription_id', $subscription_id)->orderBy('end_date', 'desc')->first();
|
||||
// Calculate the cutoff date (end date + 7 days)
|
||||
$end_date = $activity_data->end_date;
|
||||
// dd($end_date);
|
||||
$cutoffDate = Carbon::parse($end_date)->addDays(7);
|
||||
// dd($cutoffDate);
|
||||
// dd($cutoffDate,Carbon::now()->toDateString());
|
||||
// $current_date = Carbon::now()->format('Y-m-d');
|
||||
// $desired_date = Carbon::createFromDate(2024, 1, 2);
|
||||
// $cutoffDate = $desired_date->format('Y-m-d');
|
||||
// ->where('end_date','>=',$current_date)
|
||||
// dd($desired_date_formatted);
|
||||
|
||||
if(Carbon::now()->toDateString() > $cutoffDate){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Activity has ended.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$past_activity = ActivityMaster::where('subscription_id', $subscription_id)->where('end_date','<',$cutoffDate)->with('teacher_data')->orderBy('start_date', 'desc')->first();
|
||||
$schedule_data = ActivitySchedule::where('activity_master_id', $past_activity['id'])->with('past_data')->orderBy('start_date', 'asc')->get()->toArray();
|
||||
$data_schedule = [];
|
||||
foreach ($schedule_data as $k => $val){
|
||||
if (empty($val['past_data'])){
|
||||
continue;
|
||||
}else{
|
||||
$data_schedule[] = $val;
|
||||
}
|
||||
}
|
||||
$past_activity['schedule'] = $data_schedule;
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $past_activity
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// \Log::error("User data listing Failed: " . $e->getMessage());
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Something went wrong.',
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
|
||||
public function get_manage_past_session_id() {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$pastSessionId = request('pastSessionId');
|
||||
// Calculate the date 7 days before the current date
|
||||
$seven_days_before = date('Y-m-d', strtotime('+7 days'));
|
||||
|
||||
// Get past sessions that occurred within 7 days before the current date
|
||||
$passed_session = PastSession::where('created_at', '<=', $seven_days_before)
|
||||
->find($pastSessionId);
|
||||
// dd($passed_session);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $passed_session
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function add_session_status(Request $request) {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$oldUserRankings = LeaderboardMaster::with('user')
|
||||
->get();
|
||||
//get old points
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'content_id' => 'required',
|
||||
'content_type' => 'required'
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors()
|
||||
], 401);
|
||||
}
|
||||
// validation fails
|
||||
$data = UserContentView::where('user_id', $user_id)
|
||||
->whereDate('created_at', now()->toDateString())
|
||||
->get();
|
||||
|
||||
if ($data->isNotEmpty()) {
|
||||
return response([
|
||||
'status' => "Data already exists"
|
||||
], 400);
|
||||
} else {
|
||||
$add_content_view = new UserContentView;
|
||||
$add_content_view->user_id = $user_id;
|
||||
$add_content_view->content_id = $request->input('content_id');
|
||||
$add_content_view->is_view = $request->input('content_type');
|
||||
$add_content_view->save();
|
||||
|
||||
// Check if user exists in another table
|
||||
$leaderboardMaster = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
if ($leaderboardMaster) {
|
||||
// Update points if user exists
|
||||
$leaderboardMaster->total_score += 1;
|
||||
$leaderboardMaster->save();
|
||||
} else {
|
||||
// Create a new entry with 1 point if user doesn't exist
|
||||
LeaderboardMaster::create([
|
||||
'user_id' => $user_id,
|
||||
'total_score' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
$newUserRanking = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
if ($oldUserRankings && $newUserRanking) {
|
||||
foreach ($oldUserRankings as $ranking) {
|
||||
$previousTotalScore = $ranking->total_score;
|
||||
$currentTotalScore = $newUserRanking->total_score;
|
||||
if ($ranking->user_id == $user_id) {
|
||||
if ($previousTotalScore === null) {
|
||||
$ranking->progress_bar = '0'; // Initial entry
|
||||
} elseif ($currentTotalScore > $previousTotalScore) {
|
||||
$ranking->progress_bar = '0'; // Total score increased
|
||||
$message = "You earned 1 point!";
|
||||
} elseif ($currentTotalScore < $previousTotalScore) {
|
||||
$ranking->progress_bar = '1'; // Total score decreased
|
||||
$message = "Your score decreased.";
|
||||
} else {
|
||||
$ranking->progress_bar = '2'; // Total score remained the same
|
||||
$message = "Your score remains the same.";
|
||||
}
|
||||
$ranking->save(); // Save the updated progress_bar value
|
||||
}
|
||||
}
|
||||
|
||||
return response([
|
||||
'status' => "Data added successfully.",
|
||||
'progress_bar' => $message,
|
||||
], 200);
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.'
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed: " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function dummy_activity(Request $request){
|
||||
|
||||
|
||||
// try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
// dd($user_id);
|
||||
|
||||
$user_data = User::where('id',$user_id)->first();
|
||||
$utm_source = $user_data->utm_source;
|
||||
|
||||
$subscription_data = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
$subscription_id = $subscription_data->id;
|
||||
// dd($subscription_id);
|
||||
$current_day = Carbon::now()->toDateString();
|
||||
$manage_activity = ActivityDay::where('date', '=', $current_day)
|
||||
// ->where('')
|
||||
->where('subscription_id', $subscription_id)
|
||||
->with('subscription')
|
||||
->with('faq_activity_link.faqsData')
|
||||
->with('scheduleData', 'activityData.subscription')
|
||||
->with('activityData.teacher_data')
|
||||
->get();
|
||||
|
||||
// $userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// // Make a GET request to ipinfo.io
|
||||
// $response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// // Parse the JSON response
|
||||
|
||||
// $ch = curl_init("https://ipinfo.io/{$userIP}/json");
|
||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
// $response = curl_exec($ch);
|
||||
// curl_close($ch);
|
||||
|
||||
// $locationData = json_decode($response);
|
||||
|
||||
// // Extract the user's time zone from the location data
|
||||
// $userTimeZone = $locationData->timezone;
|
||||
// // dd($userTimeZone);
|
||||
// // Convert the time to the user's time zone
|
||||
// // $userTimeZone = $ca$carbonTimetz($userTimeZone);
|
||||
// $manage_activity->each(function ($item) {
|
||||
// $timestamp = $item->time;
|
||||
// $normalTime = Carbon::createFromFormat('H:i', $timestamp, 'Asia/Kolkata'); // Replace 'your_timezone' with the actual timezone of the 'time' column
|
||||
// $utcTime = $normalTime->utc();
|
||||
// $item->time = $utcTime->format('H:i'); // Update the 'time' value with the UTC time in 'HH:mm' format
|
||||
// return $item;
|
||||
// });
|
||||
// $result = $manage_activity;
|
||||
$userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// Make a GET request to ipinfo.io
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// Parse the JSON response
|
||||
$locationData = $response->json();
|
||||
|
||||
// Extract the user's time zone from the location data
|
||||
$userTimeZone = $locationData['timezone'];
|
||||
|
||||
$manage_activity->each(function ($item) use ($userTimeZone) {
|
||||
$timestamp = $item->time;
|
||||
$normalTime = Carbon::createFromFormat('H:i', $timestamp, $userTimeZone); // Replace 'your_timezone' with the actual timezone of the 'time' column
|
||||
$normalTime->setTimezone($userTimeZone); // Convert to the user's time zone
|
||||
$item->time = $normalTime->format('H:i'); // Update the 'time' value with the user's time zone in 'HH:mm' format
|
||||
return $item;
|
||||
});
|
||||
|
||||
$result = $manage_activity;
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $result
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
39
app/Http/Controllers/API/ManageBannerController.php
Normal file
39
app/Http/Controllers/API/ManageBannerController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageBanner;
|
||||
|
||||
|
||||
class ManageBannerController extends Controller
|
||||
{
|
||||
public function manage_banner()
|
||||
{
|
||||
try{
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
$user_id = $token['sub'];
|
||||
// $data = User::with('user_details')->where('id', $user_id)->first()->toArray();
|
||||
$data = ManageBanner::latest()->first();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message'=> 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
}else{
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message'=> 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
\Log::error("User data listing Failed : " .$e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message'=> 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
85
app/Http/Controllers/API/ManageFeedbackController.php
Normal file
85
app/Http/Controllers/API/ManageFeedbackController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageNewsArticles;
|
||||
use App\Models\ManageFeedback;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Auth;
|
||||
|
||||
class ManageFeedbackController extends Controller
|
||||
{
|
||||
public function getData(){
|
||||
$data = ManageFeedback::where('is_active','0')->get();
|
||||
// dd($data);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateFeedback(Request $request) {
|
||||
$token = readHeaderToken();
|
||||
// dd($token);
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
// $user = auth()->user();
|
||||
// dd($user_id);
|
||||
$existingRecord = ManageFeedback::where('user_id', $user_id)->first();
|
||||
|
||||
if ($existingRecord) {
|
||||
$existingRecord->update(['message' => $request->message,'reaction' => $request->reaction]);
|
||||
$data = $existingRecord;
|
||||
} else {
|
||||
$data = ManageFeedback::create([
|
||||
'user_id' => $user_id,
|
||||
'message' => $request->message,
|
||||
'reaction' => $request->reaction
|
||||
]);
|
||||
}
|
||||
|
||||
$message = $existingRecord ? 'Data updated successfully.' : 'Data created successfully.';
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $message,
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// public function updateFeedback(Request $request) {
|
||||
// $token = readHeaderToken();
|
||||
// if ($token) {
|
||||
// $user_id = $token['sub'];
|
||||
// $user = auth()->user();
|
||||
// // dd($user_id);
|
||||
// // Update or create ManageFeedback record
|
||||
// $data = ManageFeedback::updateOrCreate([
|
||||
// 'user_id' => $user_id,
|
||||
// 'message' => $request->message,
|
||||
// 'reaction' => $request->reaction
|
||||
// ]);
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'message' => 'Data updated successfully.',
|
||||
// 'result' => $data
|
||||
// ]);
|
||||
// } else {
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'something went wrong.',
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
121
app/Http/Controllers/API/ManageNotificationController.php
Normal file
121
app/Http/Controllers/API/ManageNotificationController.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Models\NotificationMaster;
|
||||
use App\Models\NotificationUser;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ManageNotificationController extends Controller
|
||||
{
|
||||
public function get_notification_count(){
|
||||
|
||||
try{
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
$user_id = $token['sub'];
|
||||
$notification_count = NotificationUser::where('user_id',$user_id)
|
||||
->where('is_read','0')->count();
|
||||
// print_r($notification_list);
|
||||
// exit;
|
||||
$notification_list = NotificationUser::with('notification_master_data','user_data')->where('user_id',$user_id)->get()->toArray();
|
||||
// echo "<pre>";
|
||||
// print_r($notification_list);
|
||||
// exit;
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data Fetch Successfully!.',
|
||||
'notification_count' => $notification_count,
|
||||
'notification_list' => $notification_list
|
||||
]);
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
return response([
|
||||
'status' => "failed",
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function update_read_status(Request $request){
|
||||
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$nitification_id = $request->notification_id;
|
||||
|
||||
NotificationUser::where('notification_id',$nitification_id)
|
||||
->where('user_id',$user_id)
|
||||
->update(['is_read' => '1']);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data Updated Successfully!.'
|
||||
]);
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
|
||||
} catch (Exception $ex) {
|
||||
return response([
|
||||
'status' => "failed",
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_notification(Request $request){
|
||||
|
||||
try{
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
$user_id = $token['sub'];
|
||||
$notification_id = $request->notification_id;
|
||||
|
||||
// print_r($notification_id);
|
||||
// exit;
|
||||
NotificationUser::where('notification_id',$notification_id)
|
||||
->where('user_id',$user_id)->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Deleted Successfully!.'
|
||||
]);
|
||||
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public function delete(){
|
||||
|
||||
// $threeDaysAgo = Carbon::now()->subDays(3);
|
||||
// NotificationUser::where('created_at','<',$threeDaysAgo)->delete();
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'message' => 'Deleted Successfully!.'
|
||||
// ]);
|
||||
|
||||
|
||||
// }
|
||||
}
|
||||
21
app/Http/Controllers/API/ManagePodcastController.php
Normal file
21
app/Http/Controllers/API/ManagePodcastController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManagePodcast;
|
||||
|
||||
class ManagePodcastController extends Controller
|
||||
{
|
||||
public function getPodcast(){
|
||||
|
||||
$data['latestPodcast'] = ManagePodcast::where('is_active','1')->inRandomOrder()->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
}
|
||||
}
|
||||
181
app/Http/Controllers/API/MoodOMeterController.php
Normal file
181
app/Http/Controllers/API/MoodOMeterController.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Models\mood_o_meter;
|
||||
use App\Models\LeaderboardMaster;
|
||||
//use Carbon\Carbon;
|
||||
use Auth;
|
||||
|
||||
class MoodOMeterController extends Controller {
|
||||
|
||||
public function store_mood_o_meter(Request $req) {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
// $user = auth()->user();
|
||||
$user_id = $token['sub'];
|
||||
$oldUserRankings = LeaderboardMaster::with('user')->get();
|
||||
$currentDate = now()->toDateString();
|
||||
$previousDate = now()->subDay()->toDateString();
|
||||
|
||||
// Check if a record for the current user and current day already exists
|
||||
$existingRecord = mood_o_meter::where('user_id', $user_id)
|
||||
// ->whereDate('created_at', now()->toDateString())
|
||||
->whereDate('updated_at', $currentDate)
|
||||
->where('is_active','0')
|
||||
->first();
|
||||
if ($existingRecord) {
|
||||
// Update the existing mood record
|
||||
$existingRecord->update([
|
||||
'mood_o_meter' => $req->input('mood_o_meter'),
|
||||
'is_active' => '0',
|
||||
]);
|
||||
|
||||
return response([
|
||||
'status' => "Mood already added for today",
|
||||
], 200);
|
||||
} else {
|
||||
// Check if a record for the current user and previous day exists
|
||||
// $previousRecord = mood_o_meter::where('user_id', $user_id)
|
||||
// ->whereDate('updated_at', $previousDate)
|
||||
//
|
||||
// ->first();
|
||||
|
||||
// if ($previousRecord) {
|
||||
// Create a new mood record for the current day
|
||||
mood_o_meter::where('user_id', $user_id)
|
||||
->update([
|
||||
'mood_o_meter' => $req->input('mood_o_meter'),
|
||||
'is_active' => '0'
|
||||
]);
|
||||
// }
|
||||
// else {
|
||||
//
|
||||
// mood_o_meter::create([
|
||||
// 'user_id' => $user_id,
|
||||
// 'mood_o_meter' => $req->input('mood_o_meter'),
|
||||
// 'is_active' => '0',
|
||||
// ]);
|
||||
// }
|
||||
// Update is_active column based on the current time
|
||||
$ranking = LeaderboardMaster::with('user')->where('user_id', $user_id)->first();
|
||||
// Check if user exists in another table
|
||||
$leaderboardMaster = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
if ($leaderboardMaster) {
|
||||
// Update points if user exists
|
||||
$leaderboardMaster->increment('total_score', 1);
|
||||
} else {
|
||||
// Create a new entry with 1 point if user doesn't exist
|
||||
LeaderboardMaster::create([
|
||||
'user_id' => $token['sub'],
|
||||
'total_score' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
$newUserRanking = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
if ($newUserRanking) {
|
||||
// dd($oldUserRankings);
|
||||
// $message = 'Hello World';
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($ranking);
|
||||
// exit();
|
||||
// foreach ($oldUserRankings as $ranking) {
|
||||
$previousTotalScore = $ranking->total_score;
|
||||
$currentTotalScore = $newUserRanking->total_score;
|
||||
if ($ranking->user_id == $user_id) {
|
||||
if ($previousTotalScore === null) {
|
||||
$ranking->progress_bar = '0'; // Initial entry
|
||||
} elseif ($currentTotalScore > $previousTotalScore) {
|
||||
$ranking->progress_bar = '0'; // Total score increased
|
||||
$message = "You earned 1 point!";
|
||||
} elseif ($currentTotalScore < $previousTotalScore) {
|
||||
$ranking->progress_bar = '1'; // Total score decreased
|
||||
$message = "Your score decreased.";
|
||||
} else {
|
||||
$ranking->progress_bar = '2'; // Total score remained the same
|
||||
$message = "Your score remains the same.";
|
||||
}
|
||||
$ranking->save(); // Save the updated progress_bar value
|
||||
|
||||
}
|
||||
// }
|
||||
// dd($userRanking,$newUserRanking);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'progress_bar' => $message,
|
||||
]);
|
||||
|
||||
}
|
||||
return response([
|
||||
'status' => "Success",
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
return response([
|
||||
'status' => "failed",
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get_mood_o_meter() {
|
||||
try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$data = mood_o_meter::where('user_id', $user_id)->value('is_active');
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_mood_o_meter_mood() {
|
||||
try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$data = mood_o_meter::where('user_id', $user_id)->value('mood_o_meter');
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
39
app/Http/Controllers/API/NewsAndArticleController.php
Normal file
39
app/Http/Controllers/API/NewsAndArticleController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageNewsArticles;
|
||||
use App\Models\NewsArticlesCategory;
|
||||
|
||||
class NewsAndArticleController extends Controller
|
||||
{
|
||||
public function getData(){
|
||||
$data['category'] = NewsArticlesCategory::with('articles')->where('is_active','1')->inRandomOrder()->get();
|
||||
// dd($data);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function search(Request $request)
|
||||
{
|
||||
$result = ManageNewsArticles::where('article_name', 'LIKE', '%' . $request->article_name . '%')->where('category_id',$request->category_id)->where('is_active','1')->get();
|
||||
// dd($result);
|
||||
|
||||
if (count($result) > 0) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $result]);
|
||||
} else {
|
||||
return response()->json(['Result' => 'No Data found'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
88
app/Http/Controllers/API/PeriodDatesController.php
Normal file
88
app/Http/Controllers/API/PeriodDatesController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PeriodDate;
|
||||
|
||||
class PeriodDatesController extends Controller
|
||||
{
|
||||
public function storeDates(Request $request){
|
||||
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
|
||||
$user_id = $token['sub'];
|
||||
$data = $request->all();
|
||||
// dd($data);
|
||||
// $datetime = $data['datetime'];
|
||||
$predicted_dates = $data['predicted_dates'];
|
||||
$fertile_dates = $data['fertile_dates'];
|
||||
$ovulating_dates = $data['ovulating_dates'];
|
||||
$pickerdateRange = $data['pickerdateRange'];
|
||||
|
||||
// $jsonEncodedDateTimeArray = json_encode($datetime);
|
||||
$jsonEncodedPredictedDatesArray = json_encode($predicted_dates);
|
||||
$jsonEncodedFertileDatesArray = json_encode($fertile_dates);
|
||||
$jsonEncodedOvulatingDatesArray = json_encode($ovulating_dates);
|
||||
$jsonEncodedPickerDteRangeArray = json_encode($pickerdateRange);
|
||||
|
||||
PeriodDate::updateOrCreate( ['user_id'=>$user_id],
|
||||
[
|
||||
'predicted_dates'=>$jsonEncodedPredictedDatesArray,
|
||||
'fertile_dates'=>$jsonEncodedFertileDatesArray,
|
||||
'ovulating_dates'=>$jsonEncodedOvulatingDatesArray,
|
||||
'pickerdateRange'=>$jsonEncodedPickerDteRangeArray,
|
||||
'period_cycle_length'=>$request->period_cycle_length
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data Added Successfully'
|
||||
],200);
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getPeriodDates(){
|
||||
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$data = PeriodDate::where('user_id',$user_id)->first();
|
||||
|
||||
$result['predictedDates'] = json_decode($data->predicted_dates);
|
||||
$result['fertileDates'] = json_decode($data->fertile_dates);
|
||||
$result['ovulatingDates'] = json_decode($data->ovulating_dates);
|
||||
$result['pickerdateRange'] = json_decode($data->pickerdateRange);
|
||||
$result['period_cycle_length'] = $data->period_cycle_length;
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function deletePeriodDates(){
|
||||
$token = readHeaderToken();
|
||||
if($token){
|
||||
$user_id = $token['sub'];
|
||||
// dd($user_id);
|
||||
$data = PeriodDate::where('user_id',$user_id)->delete();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data delete successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
194
app/Http/Controllers/API/ProfileController.php
Normal file
194
app/Http/Controllers/API/ProfileController.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Validator;
|
||||
use App\Models\UserDetail;
|
||||
use App\Models\CompanyMaster;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Auth;
|
||||
|
||||
class ProfileController extends Controller {
|
||||
|
||||
public function profileUpdate(Request $request) {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$user = auth()->user();
|
||||
// print_r($user);exit;
|
||||
// check validation
|
||||
$validator = Validator::make($request->all(), [
|
||||
'full_name'=>'required',
|
||||
'bio' => 'required|string|min:6',
|
||||
'description' => 'required|string|min:6',
|
||||
'gender' => 'required|in:male,female',
|
||||
'age' => 'required',
|
||||
'full_address' => 'required',
|
||||
'city' => 'required',
|
||||
'height' => 'required',
|
||||
// 'weight' => 'required',
|
||||
// 'profile_picture' => 'required|image|mimes:jpg,png,jpeg,gif',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => $validator->errors()], 401);
|
||||
}
|
||||
|
||||
$profile_completed_status = User::select('status')->find($user_id);
|
||||
if ($profile_completed_status->status == 0) {
|
||||
$UserDetail = new UserDetail;
|
||||
$UserDetail->user_id = $user_id;
|
||||
$UserDetail->user_bio = $request->input('bio');
|
||||
$UserDetail->description = $request->input('description');
|
||||
$UserDetail->gender = $request->input('gender');
|
||||
$UserDetail->age = $request->input('age');
|
||||
$UserDetail->full_address = $request->input('full_address');
|
||||
$UserDetail->city = $request->input('city');
|
||||
$UserDetail->height = $request->input('height');
|
||||
// $UserDetail->weight = $request->input('weight');
|
||||
if ($request->hasFile('profile_picture')) {
|
||||
$file = $request->file('profile_picture');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/profile_images/';
|
||||
$file->move($path, $file_name);
|
||||
$UserDetail->profile_picture = url('/public/uploads/profile_images/' . $file_name);
|
||||
}
|
||||
$UserDetail->save();
|
||||
User::where('id', $user_id)->update(array('status' => '1'));
|
||||
$msg = "Profile Completed Successfully.";
|
||||
} else {
|
||||
$user = UserDetail::where('user_id', $user_id)->first();
|
||||
// $file_name = $user->profile_picture;
|
||||
$UserDetails = UserDetail::where('user_id', $user_id)->first();
|
||||
|
||||
$UserDetails->user_bio = $request->input('bio');
|
||||
$UserDetails->description = $request->input('description');
|
||||
$UserDetails->gender = $request->input('gender');
|
||||
$UserDetails->age = $request->input('age');
|
||||
$UserDetails->full_address = $request->input('full_address');
|
||||
$UserDetails->city = $request->input('city');
|
||||
$UserDetails->height = $request->input('height');
|
||||
// 'weight' => $request->input('weight'),
|
||||
if ($request->hasFile('profile_picture')) {
|
||||
$file = $request->file('profile_picture');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/profile_images/';
|
||||
$file->move($path, $file_name);
|
||||
// delete previous file
|
||||
$previous_image = public_path('/uploads/profile_images/' . $user->profile_picture);
|
||||
$delete_prv_image = File::delete($previous_image);
|
||||
$UserDetails->profile_picture = url('/public/uploads/profile_images/' . $file_name);
|
||||
}
|
||||
// $UserDetails->profile_picture = url('/public/uploads/profile_images/' . $file_name);
|
||||
$UserDetails->save();
|
||||
User::where('id', $user_id)->update(array('full_name' => $request->input('full_name')));
|
||||
$msg = "Profile Updated Successfully.";
|
||||
}
|
||||
|
||||
$user = User::with('user_detail')->where('id', $user_id)->first()->toArray();
|
||||
// $user = User::select('id','full_name','contact_number','email_id','status')->where('id',$user->id)->first()->toArray();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => true,
|
||||
'message'=> $msg,
|
||||
'authorisation' => [
|
||||
'token' => null,
|
||||
'user_data' =>$user,
|
||||
'type' => 'bearer',
|
||||
]
|
||||
],200);
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'status' => true,
|
||||
// 'message' => $msg,
|
||||
// 'authorisation' => [
|
||||
// 'token' => null,
|
||||
// 'user_detail' =>$user,
|
||||
// 'type' => 'bearer',
|
||||
// ],
|
||||
// ]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Update Complete/Update Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created By : Pradyumn Dwivedi
|
||||
* Created at : 06 Feb 2023
|
||||
* Use : To display list of User data
|
||||
*/
|
||||
|
||||
public function index() {
|
||||
try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$data = User::with('user_detail')->where('id', $user_id)->first();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'authorisation' => [
|
||||
'user_data' => $data
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function viewProfile() {
|
||||
try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$data = User::with('user_detail')->get();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
131
app/Http/Controllers/API/QuizController.php
Normal file
131
app/Http/Controllers/API/QuizController.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageQuizQuestion;
|
||||
use App\Models\QuizQuestionsAnswer;
|
||||
use App\Models\UserQuizPoints;
|
||||
use App\Models\LeaderboardMaster;
|
||||
|
||||
class QuizController extends Controller
|
||||
{
|
||||
// public function getQuiz(){
|
||||
// $currentDateTime = now();
|
||||
// $data = $data = ManageQuizQuestion::with('answer')->where('is_active', '1')->where('schedule_timing', '=', $currentDateTime)->inRandomOrder()->limit(3)->get()->toArray();
|
||||
// // $data = $data = ManageQuizQuestion::with('answer')->where('is_active', '1')->inRandomOrder()->limit(3)->get()->toArray();
|
||||
|
||||
|
||||
// if (empty($data)) {
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'No quiz found.',
|
||||
// 'result' => []
|
||||
// ]);
|
||||
// }
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'message' => 'Data fetched successfully.',
|
||||
// 'result' => $data
|
||||
// ]);
|
||||
|
||||
// }
|
||||
|
||||
public function getQuiz() {
|
||||
$currentDateTime = now();
|
||||
|
||||
$todayQuizzes = ManageQuizQuestion::with('answer')->where('is_active', '1')->whereDate('schedule_timing', '=', $currentDateTime)->latest()->limit(3)->get()->toArray();
|
||||
|
||||
// If there are no quizzes scheduled for today or if any one quiz is inactive, fetch past quizzes
|
||||
if (count($todayQuizzes) === 0 || count($todayQuizzes) < 3) {
|
||||
$remainingSlots = 3 - count($todayQuizzes);
|
||||
|
||||
$pastQuizzes = ManageQuizQuestion::with('answer')->where('is_active', '1')->whereDate('schedule_timing', '<', $currentDateTime)->inRandom()->limit($remainingSlots)->get()->toArray();
|
||||
|
||||
// Merge today's and past quizzes
|
||||
$data = array_merge($todayQuizzes, $pastQuizzes);
|
||||
} else {
|
||||
// If there are quizzes scheduled for today, use those
|
||||
$data = $todayQuizzes;
|
||||
}
|
||||
|
||||
if (empty($data)) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'No quiz found.',
|
||||
'result' => []
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function storeQuizPoints(Request $request){
|
||||
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$currentDate = now()->toDateString(); // Extracting only the date part
|
||||
// dd($currentDate);
|
||||
|
||||
$existingRecord = UserQuizPoints::whereDate('created_at', $currentDate)
|
||||
->where('user_id', $user_id)
|
||||
->first();
|
||||
// dd($existingRecord);
|
||||
$points = $request->points*10;
|
||||
if ($existingRecord == null) {
|
||||
UserQuizPoints::create(['user_id'=>$user_id,'quize_points'=>$points,'is_active'=>'1']);
|
||||
$leaderboard = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
$leaderboard->total_score += $points;
|
||||
$leaderboard->save();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Points Adeed Succefully'
|
||||
]);
|
||||
}else{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Points Already Added'
|
||||
]);
|
||||
}
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getUerQuizpoints(){
|
||||
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$currentDate = now()->toDateString(); // Extracting only the date part
|
||||
// dd($currentDate);
|
||||
|
||||
$userQuizPoints = UserQuizPoints::whereDate('created_at', $currentDate)
|
||||
->where('user_id', $user_id)->get();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $userQuizPoints
|
||||
]);
|
||||
// dd($existingRecord);
|
||||
}else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
58
app/Http/Controllers/API/RateUsController.php
Normal file
58
app/Http/Controllers/API/RateUsController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageRateUs;
|
||||
use App\Models\ManageFeedback;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Auth;
|
||||
|
||||
class RateUsController extends Controller
|
||||
{
|
||||
public function getData(){
|
||||
$result = ManageRateUs::where('is_active','1')->get();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateRateUs(Request $request) {
|
||||
$token = readHeaderToken();
|
||||
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$user = auth()->user();
|
||||
|
||||
$existingRecord = ManageRateUs::where('user_id', $user_id)->first();
|
||||
|
||||
if ($existingRecord) {
|
||||
// If the record exists, update it
|
||||
$existingRecord->update(['rate_us' => $request->rate_us]);
|
||||
$data = $existingRecord;
|
||||
} else {
|
||||
$data = ManageRateUs::create([
|
||||
'user_id' => $user_id,
|
||||
'rate_us' => $request->rate_us,
|
||||
]);
|
||||
}
|
||||
|
||||
$message = $existingRecord ? 'Data updated successfully.' : 'Data created successfully.';
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $message,
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
56
app/Http/Controllers/API/RegisterController.php
Normal file
56
app/Http/Controllers/API/RegisterController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Validator;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
public function storeRegistrationData(Request $request)
|
||||
{
|
||||
// print_r("fghjkl");exit;
|
||||
$validator = Validator::make($request->all(),[
|
||||
'full_name'=> 'required',
|
||||
'contact_number'=> 'required',
|
||||
'email_id'=> 'required|unique:users,email_id',
|
||||
'password'=> 'required|confirmed',
|
||||
'address'=> 'required',
|
||||
'fitness_goal'=> 'required',
|
||||
'hear_about_us'=> 'required',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error'=>$validator->errors()], 401);
|
||||
}
|
||||
$data = new User;
|
||||
$data->full_name = $request->input('full_name');
|
||||
$data->contact_number = $request->input('contact_number');
|
||||
$data->email_id = $request->input('email_id');
|
||||
$data->password = Hash::make($request->input('password'));
|
||||
$data->address = $request->input('address');
|
||||
$data->fitness_goal = $request->input('fitness_goal');
|
||||
$data->hear_about = $request->input('hear_about_us');
|
||||
$register = $data->save();
|
||||
if($register == 1){
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status'=>200,
|
||||
'message'=> 'User Register Successfully',
|
||||
]);
|
||||
}else{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error'=>400,
|
||||
'message'=> 'Please Try Again',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
81
app/Http/Controllers/API/ShareYourThoughtsController.php
Normal file
81
app/Http/Controllers/API/ShareYourThoughtsController.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ShareYourThought;
|
||||
use App\Models\User;
|
||||
use App\Models\UserThought;
|
||||
use Auth;
|
||||
|
||||
class ShareYourThoughtsController extends Controller {
|
||||
|
||||
public function add_thoughts(Request $request) {
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$user = auth()->user();
|
||||
// print_r($user);exit;
|
||||
|
||||
// check validation
|
||||
// $validator = Validator::make($request->all(), [
|
||||
// 'rating' => 'required|integer|min:1|max:5',
|
||||
// ]);
|
||||
// if ($validator->fails()) {
|
||||
// return response()->json([
|
||||
// 'error' => $validator->errors()], 401);
|
||||
// }
|
||||
|
||||
$thoughts = new ShareYourThought;
|
||||
$thoughts->rating = $request->input('rating');
|
||||
$thoughts->user_id = $user_id;
|
||||
$thoughts->save();
|
||||
$msg = "Thank You Review Added Successfully.";
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $msg,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Update Complete/Update Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_thought_id() {
|
||||
try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
// $user_id = $token['sub'];
|
||||
$data = UserThought::where('is_active', '1')->inRandomOrder()->get();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
220
app/Http/Controllers/API/ShortClipsController.php
Normal file
220
app/Http/Controllers/API/ShortClipsController.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageShortClips;
|
||||
use App\Models\ShortClipsLikes;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
//use App\Models\User;
|
||||
use Validator;
|
||||
use db;
|
||||
|
||||
class ShortClipsController extends Controller {
|
||||
|
||||
// public function store_short_clips(Request $req) {
|
||||
//
|
||||
// $validator = Validator::make($req->all(), [
|
||||
// 'video_title' => 'required',
|
||||
// 'video_description' => 'required',
|
||||
// 'video_url' => 'required',
|
||||
// ]);
|
||||
// if ($validator->fails()) {
|
||||
// return response()->json([
|
||||
// 'error' => $validator->errors()], 401);
|
||||
// }
|
||||
// $shortclips = new ManageShortClips();
|
||||
// $shortclips->video_title = $req->input('video_title');
|
||||
// $shortclips->video_description = $req->input('video_description');
|
||||
// $shortclips->video_url = $req->input('video_url');
|
||||
// $shortclips->thumbnail = $req->input('thumbnail');
|
||||
// $storeclips = $shortclips->save();
|
||||
// if ($storeclips == 1) {
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'status' => 200,
|
||||
// 'message' => 'Short Clips Added Successfully',
|
||||
// ]);
|
||||
// } else {
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'error' => 400,
|
||||
// 'message' => 'Please Try Again',
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function like_short_clips(Request $request) {
|
||||
try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
// dd($user_id);
|
||||
// check validation
|
||||
$validator = Validator::make($request->all(), [
|
||||
'short_clips_id' => 'required',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors()], 401);
|
||||
}
|
||||
// check validation end
|
||||
$like = ShortClipsLikes::where('user_id', $user_id)
|
||||
->where('short_clips_id', $request->short_clips_id)
|
||||
->first();
|
||||
|
||||
if (!empty($like)) {
|
||||
if ($like->is_like == '0') {
|
||||
$like->is_like = '1';
|
||||
$like->is_active = '0';
|
||||
$like->update();
|
||||
$manage_likes = ManageShortClips::where('id', $request->short_clips_id)->first();
|
||||
if ($manage_likes->likes > 0) {
|
||||
$manage_likes->likes = $manage_likes->likes - 1;
|
||||
$manage_likes->update();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'you unliked'
|
||||
], 200);
|
||||
} else {
|
||||
$like->is_like = '0';
|
||||
$like->is_active = '1';
|
||||
$like->update();
|
||||
$manage_likes = ManageShortClips::where('id', $request->short_clips_id)->first();
|
||||
$manage_likes->likes = $manage_likes->likes + 1;
|
||||
$manage_likes->update();
|
||||
|
||||
|
||||
|
||||
return response()->json([
|
||||
'message' => 'you liked'
|
||||
], 200);
|
||||
}
|
||||
} else {
|
||||
$like = new ShortClipsLikes();
|
||||
$like->user_id = $user_id;
|
||||
$like->is_active = '1';
|
||||
$like->short_clips_id = $request->short_clips_id;
|
||||
if ($like->save()) {
|
||||
$manage_likes = ManageShortClips::where('id', $request->short_clips_id)->first();
|
||||
$manage_likes->likes = $manage_likes->likes + 1;
|
||||
$manage_likes->update();
|
||||
return response()->json([
|
||||
'message' => 'You Like a post',
|
||||
], 201);
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => "please try again"
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'likes added successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get_short_clips_by_id($id) {
|
||||
// print_r("dfghjk");
|
||||
$get_short_clips = ManageShortClips::find($id);
|
||||
// print_r($get_short_clips);
|
||||
// exit;
|
||||
}
|
||||
|
||||
public function update_short_clips(Request $request) {
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'likes' => 'required',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors()], 401);
|
||||
}
|
||||
$shortclips = ManageShortClips();
|
||||
$shortclips->likes = $req->input('likes');
|
||||
|
||||
$storeclips = $shortclips->save();
|
||||
if ($storeclips == 1) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
'message' => 'Short Clips Added Successfully',
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => 400,
|
||||
'message' => 'Please Try Again',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_short_clips() {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
// $userid = auth()->user();
|
||||
|
||||
$shortdata = ManageShortClips::where('is_active','1')->get();
|
||||
|
||||
foreach ($shortdata as $k => $val) {
|
||||
|
||||
$shortdata[$k]['thumbnail'] = ListingImageUrl('short_clips', $val['thumbnail']);
|
||||
}
|
||||
// print_r($shortdata);
|
||||
// exit;
|
||||
return response([
|
||||
'user' => $shortdata,
|
||||
// 'token' => $user->createToken('secret')->plainTextToken
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_short_clips_likes(){
|
||||
// try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
|
||||
$data = ShortClipsLikes::with('shortClicpLikes')->where('user_id', $user_id)->where('is_active','1')->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// \Log::error("User data listing Failed : " . $e->getMessage());
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Something Went wrong.',
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
108
app/Http/Controllers/API/StepCountController.php
Normal file
108
app/Http/Controllers/API/StepCountController.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\DailyStepsCount;
|
||||
use APP\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\LeaderboardMaster;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class StepCountController extends Controller
|
||||
{
|
||||
public function store_step_count(Request $request){
|
||||
|
||||
// dd($request->step_count);
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$stepCount = $request->step_count;
|
||||
$userId = $token['sub'];
|
||||
// dd($userId);
|
||||
$date = Carbon::now()->toDateString();
|
||||
$dailyStepCount = DailyStepsCount::where('user_id', $userId)
|
||||
->where('date', $date)
|
||||
->first();
|
||||
// dd($dailyStepCount);
|
||||
Log::info("dailyStepCount found at that date");
|
||||
// dd($dailyStepCount->step_count);
|
||||
|
||||
if ($dailyStepCount) {
|
||||
$oldStepCounts = $dailyStepCount->step_count;
|
||||
$oldPoints = $dailyStepCount->points;
|
||||
|
||||
// if($oldStepCounts > $stepCount){
|
||||
// $stepCount = $oldStepCounts + $stepCount;
|
||||
// }
|
||||
$dailyStepCount->update(['step_count' => $stepCount]);
|
||||
|
||||
$latestSteps = $dailyStepCount->step_count;
|
||||
// Update the step count for the current date and update points
|
||||
|
||||
$latestPoints = intval(floor($latestSteps/1000));
|
||||
if($latestPoints > $oldPoints){
|
||||
$currentPoints = $latestPoints - $oldPoints;
|
||||
|
||||
//update points
|
||||
$dailyStepCount->update(['points' => $latestPoints]);
|
||||
|
||||
$leaderboardMaster = LeaderboardMaster::where('user_id', $userId)->first();
|
||||
|
||||
if ($leaderboardMaster) {
|
||||
// $latestPoints = $latestPoints*5;
|
||||
$leaderboardMaster->total_score += 5*$currentPoints;
|
||||
$leaderboardMaster->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$updated_step_counts = $points = intval(floor($dailyStepCount->step_count/1000));
|
||||
$updated_points = $dailyStepCount->points;
|
||||
if($updated_step_counts < $updated_points){
|
||||
$leaderboardMaster = LeaderboardMaster::where('user_id', $userId)->first();
|
||||
if ($leaderboardMaster) {
|
||||
|
||||
$leaderboardMaster->total_score -= 5*$updated_points;
|
||||
$leaderboardMaster->total_score += 5*$updated_step_counts;
|
||||
$leaderboardMaster->save();
|
||||
}
|
||||
$dailyStepCount->update(['points' => $updated_step_counts]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
Log::info("New user Creating");
|
||||
// Create a new record for the new day
|
||||
$points = intval(floor($stepCount/1000));
|
||||
$newDailyStepCount = new DailyStepsCount([
|
||||
'user_id' => $userId,
|
||||
'date' => $date,
|
||||
'step_count' => $stepCount,
|
||||
'points' => $points,
|
||||
]);
|
||||
|
||||
$newDailyStepCount->save();
|
||||
|
||||
$leaderboardMaster = LeaderboardMaster::where('user_id', $userId)->first();
|
||||
if ($leaderboardMaster) {
|
||||
|
||||
$leaderboardMaster->total_score += 5*$points;
|
||||
$leaderboardMaster->save();
|
||||
}
|
||||
}
|
||||
|
||||
return response(['status' => "Success"], 200);
|
||||
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
76
app/Http/Controllers/API/TestimonialController.php
Normal file
76
app/Http/Controllers/API/TestimonialController.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Testimonial;
|
||||
use App\Models\TestimonialImages;
|
||||
use Validator;
|
||||
|
||||
|
||||
class TestimonialController extends Controller
|
||||
{
|
||||
public function get_Testimonial() {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$testdata = Testimonial::with('testimonial_data')->inRandomOrder()->get();
|
||||
// echo "<pre>";
|
||||
// print_r($testdata);
|
||||
// exit;
|
||||
// foreach ($testdata as $val) {
|
||||
|
||||
// foreach($val['testimonial_data'] as $k =>$image){
|
||||
// $testdata[$k]['image'] = ListingImageUrl('testimonial', $val['image']);
|
||||
// }
|
||||
|
||||
// }
|
||||
return response([
|
||||
'user' => $testdata,
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function store_testimonial(Request $req) {
|
||||
|
||||
$validator = Validator::make($req->all(), [
|
||||
'user_name' => 'required',
|
||||
'image' => 'required|image|mimes:jpg,png,jpeg,gif',
|
||||
'title' => 'required',
|
||||
'description' => 'required',
|
||||
'rating' => 'required',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'error' => $validator->errors()], 401);
|
||||
}
|
||||
$testimonials = new Testimonial();
|
||||
$testimonials->user_name = $req->input('user_name');
|
||||
// $testimonials->image = $req->input('image');
|
||||
$testimonials->title = $req->input('title');
|
||||
$testimonials->description = $req->input('description');
|
||||
$testimonials->rating = $req->input('rating');
|
||||
if ($req->hasFile('image')) {
|
||||
$file = $req->file('image');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/testimonial/';
|
||||
$file->move($path, $file_name);
|
||||
$testimonials->image = url('/public/uploads/testimonial/' . $file_name);
|
||||
}
|
||||
$storetestimonial = $testimonials->save();
|
||||
if ($storetestimonial == 1) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
'message' => 'Testimonial Added Successfully',
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => 400,
|
||||
'message' => 'Please Try Again',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
73
app/Http/Controllers/API/UserController.php
Normal file
73
app/Http/Controllers/API/UserController.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Auth;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function userSubscriptionData(){
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
// dd($user_id);
|
||||
$result = User::where('id', $user_id)->where('is_active', '0')->first(['id', 'utm_source', 'start_date', 'end_date']);
|
||||
if ($result) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $result
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'User not found.'
|
||||
], 404);
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token not provided.'
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_user() {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
// dd($user_id);
|
||||
$user = User::find($user_id);
|
||||
// dd($user);
|
||||
if ($user) {
|
||||
$data = $user->delete();
|
||||
if ($data) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'User deleted successfully.',
|
||||
'result' => $user
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Failed to delete user.'
|
||||
], 500);
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'User not found.'
|
||||
], 404);
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token not provided.'
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
}
|
||||
329
app/Http/Controllers/API/UserOverviewController.php
Normal file
329
app/Http/Controllers/API/UserOverviewController.php
Normal file
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\UserOverView;
|
||||
use App\Models\LeaderboardMaster;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDetail;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Validator;
|
||||
use Auth;
|
||||
use App\Models\ActivityMaster;
|
||||
|
||||
class UserOverviewController extends Controller {
|
||||
|
||||
public function add_user_overview(Request $req) {
|
||||
|
||||
try {
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$todaysDate = Carbon::now()->toDateString();
|
||||
// dd($todaysDate);
|
||||
$oldUserRankings = LeaderboardMaster::with('user')->get();
|
||||
$result = UserOverView::where("user_id", $user_id)
|
||||
->where('created_at', $todaysDate)
|
||||
// ->orderBy('created_at', 'desc')
|
||||
->exists();
|
||||
if ($result) {
|
||||
$lastOverview = UserOverView::where('user_id', $user_id)
|
||||
->orderBy('created_at', 'desc')
|
||||
// ->skip(1)
|
||||
->first();
|
||||
UserOverView::where('user_id', $user_id)
|
||||
->whereDay('created_at', now()->day)
|
||||
->update([
|
||||
"muscle_rate" => $req->muscle_rate,
|
||||
"body_fat" => $req->body_fat,
|
||||
"skeletal_muscle" => $req->skeletal_muscle,
|
||||
"protein" => $req->protein,
|
||||
"bmr" => $req->bmr,
|
||||
"water" => $req->water,
|
||||
"age" => $req->age,
|
||||
"weight" => $req->weight,
|
||||
]);
|
||||
$points = (100 - $req->body_fat) + $req->muscle_rate;
|
||||
|
||||
$leaderboard = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
if ($leaderboard) {
|
||||
// $lastOverview = UserOverView::where('user_id', $user_id)
|
||||
// ->orderBy('created_at', 'desc')
|
||||
// // ->skip(1)
|
||||
// ->first();
|
||||
if ($lastOverview) {
|
||||
$pointsToDeduct = (100 - $lastOverview->body_fat) + $lastOverview->muscle_rate;
|
||||
$leaderboard->total_score -= $pointsToDeduct;
|
||||
// dd($leaderboard);
|
||||
// Ensure total_score is not negative
|
||||
if ($leaderboard->total_score < 0) {
|
||||
$leaderboard->total_score = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$leaderboard->total_score += $points;
|
||||
|
||||
|
||||
}
|
||||
$leaderboard->save();
|
||||
|
||||
$msg = "User Overview Updated Successfully.";
|
||||
} else {
|
||||
$tellobj = new UserOverView();
|
||||
$tellobj->user_id = $user_id;
|
||||
$tellobj->muscle_rate = $req->muscle_rate;
|
||||
$tellobj->body_fat = $req->body_fat;
|
||||
$tellobj->skeletal_muscle = $req->skeletal_muscle;
|
||||
$tellobj->protein = $req->protein;
|
||||
$tellobj->bmr = $req->bmr;
|
||||
$tellobj->water = $req->water;
|
||||
$tellobj->age = $req->age;
|
||||
$tellobj->weight = $req->weight;
|
||||
$tellobj->save();
|
||||
|
||||
// Calculate points based on body_fat and muscle_rate
|
||||
$points = (100 - $req->body_fat) + $req->muscle_rate ;
|
||||
|
||||
$userDetails = UserDetail::where('user_id', $user_id)->first();
|
||||
if ($userDetails && $userDetails->gender == 'female') {
|
||||
$points += 25;
|
||||
}else{
|
||||
$points += 1;
|
||||
}
|
||||
|
||||
$leaderboard = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
if ($leaderboard) {
|
||||
// Deduct points from yesterday's overview
|
||||
$lastOverview = UserOverView::where('user_id', $user_id)
|
||||
->orderBy('created_at', 'desc')
|
||||
->skip(1)
|
||||
->first();
|
||||
if ($lastOverview) {
|
||||
$pointsToDeduct = (100 - $lastOverview->body_fat) + $lastOverview->muscle_rate ;
|
||||
$leaderboard->total_score -= $pointsToDeduct;
|
||||
// Ensure total_score is not negative
|
||||
if ($leaderboard->total_score < 0) {
|
||||
$leaderboard->total_score = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$leaderboard->total_score += $points;
|
||||
} else {
|
||||
$leaderboard = new LeaderboardMaster();
|
||||
$leaderboard->user_id = $user_id;
|
||||
$leaderboard->total_score = $points;
|
||||
}
|
||||
|
||||
$leaderboard->save();
|
||||
|
||||
$msg = "User Overview Added Successfully.";
|
||||
}
|
||||
|
||||
// Decrease 5 point for every 3 days since the previous overview
|
||||
$lastOverview = UserOverView::where('user_id', $user_id)
|
||||
->orderBy('created_at', 'desc')
|
||||
->skip(1)
|
||||
->first();
|
||||
|
||||
if ($lastOverview) {
|
||||
$daysSinceLastOverview = $lastOverview->created_at->diffInDays(now());
|
||||
$pointsToDeduct = floor($daysSinceLastOverview / 3);
|
||||
|
||||
$leaderboard = LeaderboardMaster::where('user_id', $user_id)->first();
|
||||
if ($leaderboard) {
|
||||
$leaderboard->total_score -= $pointsToDeduct;
|
||||
$leaderboard->save();
|
||||
}
|
||||
}
|
||||
$newUserRanking = LeaderboardMaster::where('user_id',$user_id)->first();
|
||||
if ($oldUserRankings && $newUserRanking) {
|
||||
foreach ($oldUserRankings as $ranking) {
|
||||
$previousTotalScore = $ranking->total_score;
|
||||
$currentTotalScore = $newUserRanking->total_score;
|
||||
if($ranking->user_id==$user_id){
|
||||
if ($previousTotalScore === null) {
|
||||
$ranking->progress_bar = '0'; // Initial entry
|
||||
} elseif ($currentTotalScore > $previousTotalScore) {
|
||||
$ranking->progress_bar = '0'; // Total score increased
|
||||
$message = "You earned 1 point!";
|
||||
} elseif ($currentTotalScore < $previousTotalScore) {
|
||||
$ranking->progress_bar = '1'; // Total score decreased
|
||||
$message = "Your score decreased.";
|
||||
} else {
|
||||
$ranking->progress_bar = '2'; // Total score remained the same
|
||||
$message = "Your score remains the same.";
|
||||
}
|
||||
|
||||
$ranking->save(); // Save the updated progress_bar value
|
||||
}
|
||||
|
||||
}
|
||||
// dd($userRanking,$newUserRanking);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $msg,
|
||||
'progress_bar' => $message,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}catch (\Exception $e) {
|
||||
\Log::error("Update Complete/Update Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function get_user_overview_by_id() {
|
||||
try {
|
||||
// print_r(User::first()->user);exit;
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
$user_id = $token['sub'];
|
||||
$data = UserOverView::where('user_id', $user_id)->get();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'result' => $data
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function show_user_overview(Request $request) {
|
||||
// dd($request->created_at);
|
||||
// try {
|
||||
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
// dd($request->created_at);
|
||||
$user_id = $token['sub'];
|
||||
if($request->created_at)
|
||||
{
|
||||
$data = UserOverView::where('user_id',$user_id)->where('created_at', $request->created_at)->first();
|
||||
}else{
|
||||
$data = UserOverView::where('user_id',$user_id)->get();
|
||||
}
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'authorisation' => [
|
||||
'user_data' => $data
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// \Log::error("User data listing Failed : " . $e->getMessage());
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'message' => 'Something Went wrong.',
|
||||
// ]);
|
||||
// }
|
||||
}
|
||||
|
||||
public function showUserOverview_new(Request $request){
|
||||
|
||||
// dd($request->created_at);
|
||||
try {
|
||||
|
||||
$token = readHeaderToken();
|
||||
if ($token) {
|
||||
// dd($request->created_at);
|
||||
$user_id = $token['sub'];
|
||||
if($request->created_at)
|
||||
{
|
||||
$data = UserOverView::where('user_id',$user_id)->where('created_at', $request->created_at)->first();
|
||||
}else{
|
||||
|
||||
if($request->data == "week"){
|
||||
$last7Days = Carbon::now()->subDays(7);
|
||||
$data = UserOverView::where('user_id',$user_id)->where('created_at','>=',$last7Days)->get();
|
||||
}elseif($request->data == "month"){
|
||||
$last30Days = Carbon::now()->subDays(30);
|
||||
$data = UserOverView::where('user_id',$user_id)->where('created_at','>=',$last30Days)->get();
|
||||
}elseif($request->data == "year"){
|
||||
$lastYear = Carbon::now()->subYear();
|
||||
// dd($lastYear);
|
||||
$data = UserOverView::where('user_id',$user_id)->where('created_at','>=',$lastYear)->get();
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data fetched successfully.',
|
||||
'authorisation' => [
|
||||
'user_data' => $data
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Authentication failed.',
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("User data listing Failed : " . $e->getMessage());
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Something Went wrong.',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function resetPoints(){
|
||||
|
||||
$currentDate = date('Y-m-d');
|
||||
$activityData = ActivityMaster::orderBy('id','desc')->first();
|
||||
if($activityData){
|
||||
$start_date = $activityData->start_date;
|
||||
if($currentDate < $start_date){
|
||||
$leaderBoaradData = LeaderboardMaster::all();
|
||||
// dd($leaderBoaradData);
|
||||
foreach($leaderBoaradData as $data){
|
||||
LeaderboardMaster::where('user_id',$data->user_id)->update(['total_score' => 0]);
|
||||
}
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Reset Succefully'
|
||||
],200);
|
||||
}else{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Season is not end yet!'
|
||||
],201);
|
||||
}
|
||||
}else{
|
||||
return response()->json([
|
||||
'success' => flase,
|
||||
'message' => 'No Activity Found'
|
||||
],404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
20
app/Http/Controllers/API/ViewDevicesOneSignalController.php
Normal file
20
app/Http/Controllers/API/ViewDevicesOneSignalController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ViewDevicesOneSignalController extends Controller
|
||||
{
|
||||
function fetchDevices() {
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->request('GET', 'https://onesignal.com/api/v1/players?app_id=1be4b99b-8faa-45b8-ad82-c66225d77bf4&limit=10&offset=0', [
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic MWM2NGEyODUtN2U5MS00MzlkLWJhYmItZGUyODRjYTlmNGJm',
|
||||
'accept' => 'text/plain',
|
||||
],
|
||||
]);
|
||||
return $response->getBody();
|
||||
}
|
||||
}
|
||||
48
app/Http/Controllers/Admin/AboutUsController.php
Normal file
48
app/Http/Controllers/Admin/AboutUsController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManageAboutUsService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AboutUsController extends Controller
|
||||
{
|
||||
public function __construct(ManageAboutUsService $manageAboutUsService)
|
||||
{
|
||||
$this->manageAboutUsService = $manageAboutUsService;
|
||||
}
|
||||
|
||||
public function view_about_us(){
|
||||
|
||||
$about_us['about_us'] = $this->manageAboutUsService->view_about_us()->toArray();
|
||||
// echo "<pre>";
|
||||
// print_r($about_us);
|
||||
// echo "</pre>";exit;
|
||||
|
||||
// dd($about_us);
|
||||
return view('Admin.Pages.manage_cms.about_us.about_us',$about_us);
|
||||
}
|
||||
|
||||
public function edit_about_us($id)
|
||||
{
|
||||
$about_us['about_us'] = $this->manageAboutUsService->edit_about_us($id)->toArray();
|
||||
// echo "<pre>";
|
||||
// print_r($about_us);
|
||||
// echo "</pre>";exit;
|
||||
return view('Admin.Pages.manage_cms.about_us.edit_about_us',$about_us);
|
||||
}
|
||||
|
||||
public function update_about_us(Request $request)
|
||||
{
|
||||
$edit_about_us = $this->manageAboutUsService->update_about_us($request);
|
||||
if(!empty($edit_about_us))
|
||||
{
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
305
app/Http/Controllers/Admin/ActivityDaysController.php
Normal file
305
app/Http/Controllers/Admin/ActivityDaysController.php
Normal file
@@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ActivityMaster;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use App\Models\ActivitySchedule;
|
||||
use App\Models\ActivityDay;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\ManageFaq;
|
||||
use App\Models\LinkFaqActivityMasterIds;
|
||||
use App\Models\PastSession;
|
||||
use File;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ActivityDaysController extends Controller {
|
||||
|
||||
// public function show($id){
|
||||
//
|
||||
// $manage_activity_day = ActivityDay::where('activity_schedule_id', $id)->with('scheduleData','activityData')
|
||||
//// ->where('start_date', '<=',$current_day)
|
||||
//// ->where('end_date', '>=',$current_day)
|
||||
//// ->where()
|
||||
// ->get()
|
||||
// ->toArray();
|
||||
//// echo "<pre>"; print_r($manage_activity_day);exit;
|
||||
// return view('Admin.Pages.manage_activities.activity_days.activity_days')->with(['manage_activity_day' => $manage_activity_day]);
|
||||
// }
|
||||
|
||||
public function show($id) {
|
||||
$current_day = now()->format('Y-m-d'); // Get the current date in the format "YYYY-MM-DD"
|
||||
|
||||
$manage_activity_day = ActivityDay::where('activity_schedule_id', $id)
|
||||
->with('scheduleData', 'activityData')
|
||||
->where('date', 'LIKE', "%$current_day%") // Check if the current date is present in the "days" column
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
return view('Admin.Pages.manage_activities.activity_days.activity_days')->with(['manage_activity_day' => $manage_activity_day]);
|
||||
}
|
||||
|
||||
public function add($id) {
|
||||
// dd($id);
|
||||
$get_single_schedule = ActivitySchedule::find($id)->toArray();
|
||||
// echo '<pre>';print_r($get_single_schedule);exit;
|
||||
// dd($get_single_schedule);
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
return view('Admin.Pages.manage_activities.activity_days.add_activity_days')->with(['get_schedule_data' => $get_single_schedule, 'subcriptions' => $subcription]);
|
||||
}
|
||||
|
||||
public function add_upcoming($id) {
|
||||
|
||||
$get_single_schedule = ActivitySchedule::find($id)->toArray();
|
||||
// echo '<pre>';print_r($get_single_schedule);exit;
|
||||
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
return view('Admin.Pages.manage_activities.activity_days.add_upcoming_activity_day')->with(['get_schedule_data' => $get_single_schedule, 'subcriptions' => $subcription]);
|
||||
}
|
||||
|
||||
public function add_data(Request $request) {
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_day';
|
||||
$file->move($path, $file_name);
|
||||
}
|
||||
$activity_day = new ActivityDay;
|
||||
$activity_day->activity_master_id = $request->input('activity_id');
|
||||
$activity_day->activity_schedule_id = $request->input('schedule_id');
|
||||
$activity_day->activity_name = $request->input('main_activity_name');
|
||||
$activity_day->activity_teaser = url('/public/uploads/activity_banner_images/activity_day/' . $file_name);
|
||||
$activity_day->activity_duration = $request->input('activity_duration');
|
||||
$activity_day->description = $request->input('description');
|
||||
$activity_day->date = $request->input('date');
|
||||
$activity_day->day = $request->input('day');
|
||||
$activity_day->time = $request->input('time');
|
||||
$activity_day->zoom_link = $request->input('zoom_link');
|
||||
$activity_day->subscription_id = $request->input('subscription_id');
|
||||
|
||||
$date = strtotime($request->input('date'));
|
||||
// Retrieve the ActivityMaster record
|
||||
$activity_schedule = ActivitySchedule::find($request->input('schedule_id'));
|
||||
|
||||
$activity_shedule_start_date = strtotime($activity_schedule->start_date);
|
||||
$activity_shedule_end_date = strtotime($activity_schedule->end_date);
|
||||
if ($date >= $activity_shedule_start_date && $date <= $activity_shedule_end_date) {
|
||||
$activity_day->save();
|
||||
return response()->json([
|
||||
'schedule_data' => $activity_day->activity_schedule_id,
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Start date or end date is not within the activity master range.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function add_upcoming_data(Request $request) {
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_day';
|
||||
$file->move($path, $file_name);
|
||||
}
|
||||
|
||||
$activity_day = new ActivityDay;
|
||||
$activity_day->activity_master_id = $request->input('activity_id');
|
||||
$activity_day->activity_schedule_id = $request->input('schedule_id');
|
||||
$activity_day->activity_name = $request->input('main_activity_name');
|
||||
$activity_day->activity_teaser = url('/public/uploads/activity_banner_images/activity_day/' . $file_name);
|
||||
$activity_day->activity_duration = $request->input('activity_duration');
|
||||
$activity_day->description = $request->input('description');
|
||||
$activity_day->date = $request->input('date');
|
||||
$activity_day->day = $request->input('day');
|
||||
$activity_day->time = $request->input('time');
|
||||
$activity_day->subscription_id = $request->input('subscription_id');
|
||||
$activity_day->zoom_link = $request->input('zoom_link');
|
||||
|
||||
$date = strtotime($request->input('date'));
|
||||
// Retrieve the ActivityMaster record
|
||||
$activity_schedule = ActivitySchedule::find($request->input('schedule_id'));
|
||||
|
||||
$activity_shedule_start_date = strtotime($activity_schedule->start_date);
|
||||
$activity_shedule_end_date = strtotime($activity_schedule->end_date);
|
||||
if ($date >= $activity_shedule_start_date && $date <= $activity_shedule_end_date) {
|
||||
$activity_day->save();
|
||||
return response()->json([
|
||||
'schedule_data' => $activity_day->activity_schedule_id,
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Start date or end date is not within the activity master range.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit_activity_day($id) {
|
||||
$manage_activity_day = ActivityDay::where('id', $id)->with('scheduleData', 'activityData')
|
||||
->get()
|
||||
->toArray();
|
||||
// echo "<pre>"; print_r($manage_activity_day);exit;
|
||||
// return view('Admin.Pages.manage_activities.activity_days.activity_days')->with(['manage_activity_day' => $manage_activity_day]);
|
||||
// }
|
||||
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
|
||||
return view('Admin.Pages.manage_activities.activity_days.edit_activity_days')->with(['manage_activity_day' => $manage_activity_day, 'subcriptions' => $subcription]);
|
||||
}
|
||||
|
||||
//upcoming edit
|
||||
|
||||
public function edit_upcoming_activity_day($id) {
|
||||
$manage_activity_day = ActivityDay::where('id', $id)->with('scheduleData', 'activityData')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
return view('Admin.Pages.manage_activities.activity_days.edit_upcoming_activity_day')->with(['manage_activity_day' => $manage_activity_day, 'subcriptions' => $subcription]);
|
||||
}
|
||||
|
||||
public function edit_activity_day_data(Request $request) {
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$activity_day = ActivityDay::find($request->edit_main_activity_id);
|
||||
$activity_day->activity_name = $request->input('activity_name');
|
||||
if ($request->file('activity_teaser')) {
|
||||
$rules = [
|
||||
'activity_teaser' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('activity_teaser');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_day/';
|
||||
$file->move($path, $file_name);
|
||||
$file_name_store = url('/public/uploads/activity_banner_images/activity_day/' . $file_name);
|
||||
$activity_day->activity_teaser = url('/public/uploads/activity_banner_images/activity_day/' . $file_name);
|
||||
}
|
||||
// print_r($file_name_store);exit;
|
||||
}
|
||||
$activity_day->activity_duration = $request->input('activity_duration');
|
||||
$activity_day->description = $request->input('description');
|
||||
$activity_day->date = $request->input('date');
|
||||
$activity_day->day = $request->input('day');
|
||||
$activity_day->time = $request->input('time');
|
||||
$activity_day->zoom_link = $request->input('zoom_link');
|
||||
$activity_day->subscription_id = $request->input('subscription_id');
|
||||
$activity_day->save();
|
||||
return response()->json(['success' => true, 'status' => 200,'day_data'=>$request->activity_schedule_master_id]);
|
||||
}
|
||||
|
||||
public function edit_upcoming_activity_day_data(Request $request) {
|
||||
|
||||
// echo '<pre>';
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$activity_day = ActivityDay::find($request->edit_main_activity_id);
|
||||
$activity_day->activity_name = $request->input('activity_name');
|
||||
if ($request->activity_teaser) {
|
||||
$rules = [
|
||||
'activity_teaser' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('activity_teaser');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_day/';
|
||||
$file->move($path, $file_name);
|
||||
$file_name_store = url('/public/uploads/activity_banner_images/activity_day/' . $file_name);
|
||||
$activity_day->activity_teaser = url('/public/uploads/activity_banner_images/activity_day/' . $file_name);
|
||||
}
|
||||
// print_r($file_name_store);exit;
|
||||
}
|
||||
$activity_day->activity_duration = $request->input('activity_duration');
|
||||
$activity_day->description = $request->input('description');
|
||||
$activity_day->date = $request->input('date');
|
||||
$activity_day->day = $request->input('day');
|
||||
$activity_day->time = $request->input('time');
|
||||
|
||||
$activity_day->zoom_link = $request->input('zoom_link');
|
||||
$activity_day->subscription_id = $request->input('subscription_id');
|
||||
$activity_day->save();
|
||||
return response()->json(['success' => true, 'status' => 200,'day_data'=>$request->activity_schedule_master_id]);
|
||||
}
|
||||
|
||||
public function upcomimg_days_show($id) {
|
||||
$current_day = now()->format('Y-m-d'); // Get the current date in the format "YYYY-MM-DD"
|
||||
|
||||
$manage_activity_day = ActivityDay::where('activity_schedule_id', $id)
|
||||
->with('scheduleData', 'activityData')
|
||||
->where('date', '>', "$current_day") // Check if the current date is present in the "days" column
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
return view('Admin.Pages.manage_activities.activity_days.upcoming_activity_days')->with(['manage_activity_day' => $manage_activity_day]);
|
||||
}
|
||||
|
||||
public function delete_activity_days($id) {
|
||||
// print_r($id);
|
||||
// exit;
|
||||
$manage_activity_days = ActivityDay::find($id)->delete();
|
||||
}
|
||||
|
||||
}
|
||||
32
app/Http/Controllers/Admin/DashboardController.php
Normal file
32
app/Http/Controllers/Admin/DashboardController.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Models\LeaderboardMaster;
|
||||
use Auth;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
// public function index(){
|
||||
//// $userCount = User::count();
|
||||
// return view('Admin.dashboard')->with(['user_count' => $userCount]);
|
||||
// }
|
||||
|
||||
public function view_dashboard() {
|
||||
// dd(Auth::user());
|
||||
$manage_dashboard = LeaderboardMaster::with('user')->get()->toArray();
|
||||
// echo "<pre>";
|
||||
// print_r($manage_dashboard);
|
||||
// exit();
|
||||
|
||||
// Sort the $manage_dashboard array by the 'total_score' attribute in descending order
|
||||
usort($manage_dashboard, function($a, $b) {
|
||||
return $b['total_score'] <=> $a['total_score'];
|
||||
});
|
||||
return view('Admin.dashboard')->with(['manage_dashboard' => $manage_dashboard]);
|
||||
|
||||
}
|
||||
}
|
||||
46
app/Http/Controllers/Admin/DirectUserController.php
Normal file
46
app/Http/Controllers/Admin/DirectUserController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDetail;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Imports\UserImport;
|
||||
use Hash;
|
||||
|
||||
class DirectUserController extends Controller
|
||||
{
|
||||
public function users(){
|
||||
$data = User::with('user_detail')->get()->toArray();
|
||||
|
||||
// dd($data);
|
||||
return view('Admin.Pages.direct_users.direct_user')->with(['user_data'=> $data]);
|
||||
}
|
||||
|
||||
public function import(Request $request)
|
||||
{
|
||||
try {
|
||||
$validation = $request->validate([
|
||||
'csv_file' => 'required|mimes:csv,txt,xlsx',
|
||||
]);
|
||||
// dd($request->all());
|
||||
// Use try-catch to handle exceptions thrown by Excel::import
|
||||
// try {
|
||||
Excel::import(new UserImport, $request->file('csv_file'));
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
// } catch (ValidationException $e) {
|
||||
// // Catch the validation exception and extract errors
|
||||
// $errors = $e->validator->errors()->toArray();
|
||||
|
||||
// return response()->json(['errors' => $errors], 422); // 422 Unprocessable Entity
|
||||
// }
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => 'Error importing data: ' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
346
app/Http/Controllers/Admin/LoginController.php
Normal file
346
app/Http/Controllers/Admin/LoginController.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\AdminMaster;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\SignInOtpMail;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Crypt;
|
||||
use Hash;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use DateInterval;
|
||||
// use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LoginController extends Controller {
|
||||
|
||||
public function create()
|
||||
{
|
||||
|
||||
return view('Admin.sign_in');
|
||||
}
|
||||
public function getOTP()
|
||||
{
|
||||
$data = array();
|
||||
$data['data'] = $_GET['d'];
|
||||
// echo"<pre>"; print_r($data);exit;
|
||||
return view('Admin.two_steps',$data);
|
||||
}
|
||||
|
||||
// public function sendOtp(Request $request)
|
||||
// {
|
||||
// try {
|
||||
// $msg_data = array();
|
||||
// $validationErrors = $this->validateLogin($request);
|
||||
// if (count($validationErrors)) {
|
||||
// \Log::error("Auth Exception: " . implode(", ", $validationErrors->all()));
|
||||
// $msg_data['data'] = array("success" => '0', "message" => implode("\n", $validationErrors->all()));
|
||||
// return response()->json($msg_data);
|
||||
// }
|
||||
// $email = trim(strtolower($request->email));
|
||||
// //check admin exist with this email or not
|
||||
// $admin_exits = AdminMaster::where('email_id', $email)->get();
|
||||
// // echo "<pre>";
|
||||
// // print_r($admin_exits[0]->password);
|
||||
// // die;
|
||||
// if (empty($admin_exits)) {
|
||||
// $msg_data['data'] = array(
|
||||
// "success" => '0',
|
||||
// "message" => "Admin does not exist");
|
||||
// return response()->json($msg_data);
|
||||
// }
|
||||
// //verifying password from table
|
||||
// $password = md5($request->password);
|
||||
//
|
||||
// // print_r($admin_exit."<br>");
|
||||
// if ($password == $admin_exits[0]->password)
|
||||
// {
|
||||
// $admin_data = AdminMaster::where('email_id', $email)->where('pin', $request->digit_pin)->first();
|
||||
// if (empty($admin_data))
|
||||
// {
|
||||
// \Log::error("Admin not found with this email id and pin is incorrect.");
|
||||
// $msg_data['data'] = array("success" => '0', "message" => "Please enter correct pin!");
|
||||
// return response()->json($msg_data);
|
||||
// }
|
||||
//
|
||||
// if ($admin_data->is_active == 1) {
|
||||
// // print_r($admin_data->is_active);
|
||||
// // die;
|
||||
// // \Log::info("Login Successful!");
|
||||
// $enc_data = Crypt::encrypt($email);
|
||||
// // print_r($enc_data);
|
||||
// // die;
|
||||
// //update otp to table
|
||||
// $otp_data = array();
|
||||
// $otp_data['otp'] = $otp = generateRandomOTP();
|
||||
// $checkOtp = AdminMaster::where('email_id', $email)->first();
|
||||
// $update_otp = AdminMaster::find($checkOtp->id); //->update($otp_data);
|
||||
// $update_otp->otp = $otp;
|
||||
// $update_otp->save();
|
||||
// // print_r($update_otp);
|
||||
// // die;
|
||||
//
|
||||
// //send email otp section start
|
||||
// // $body = "Login Verification, please use the verification code to sign in Code " . $otp;
|
||||
// // Mail::send("Admin.auth.send_otp", ['body'=> $body], function ($message) use ($email) {
|
||||
// // $message->from('pradyumn@wdimails.com', 'WOKA');
|
||||
// // $message->to($email, 'WOKA')->subject('Woka Sign in OTP');
|
||||
// // });
|
||||
//
|
||||
// $msg_data['data'] = array("success" => '1', "message" => "OTP has been sent to your mails. " . $otp, "redirect" => "two_step", "email" => $enc_data);
|
||||
// return response()->json($msg_data);
|
||||
// } else {
|
||||
// \Log::error("Account Suspended.");
|
||||
// $msg_data['data'] = array("success" => '0', "message" => 'Account is suspended.');
|
||||
// return response()->json($msg_data);
|
||||
// }
|
||||
// return response()->json($msg_data);
|
||||
// } else
|
||||
// {
|
||||
// $msg_data['data'] = array("success" => '0', "message" => 'Incorrect Password.');
|
||||
// return response()->json($msg_data);
|
||||
// }
|
||||
// return response()->json($msg_data);
|
||||
// } catch (\Exception $e) {
|
||||
// \Log::error("Login failed: " . $e->getMessage());
|
||||
// return response()->json(array("success" => '0', "message" => 'Something Went Wrong.'));
|
||||
// }
|
||||
// }
|
||||
|
||||
public function sendOtp(Request $request)
|
||||
{
|
||||
try {
|
||||
$msg_data = array();
|
||||
$validationErrors = $this->validateLogin($request);
|
||||
// print_r($validationErrors); exit;
|
||||
if (count($validationErrors)) {
|
||||
\Log::error("Auth Exception: " . implode(", ", $validationErrors->all()));
|
||||
$msg_data['data'] = array("success" => '0', "message" => implode("\n", $validationErrors->all()));
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
|
||||
$email = trim(strtolower($request->email));
|
||||
//check admin exist with this email or not
|
||||
$admin_exits = AdminMaster::where('email_id', $email)->first();
|
||||
// print_r($admin_exits); exit;
|
||||
if (empty($admin_exits)){
|
||||
$msg_data['data'] = array(
|
||||
"success" => '0',
|
||||
"message" => "Admin does not exist!");
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
//verifying password from table
|
||||
// print_r($admin_exits->password);exit;
|
||||
//dd( (Hash::check(trim($request->password), $admin_exits->password) )
|
||||
// ,$request->password,$admin_exits->password);
|
||||
$verify_pass = Hash::check($request->password,$admin_exits->password);
|
||||
// print_r($verify_pass); exit;
|
||||
if ($verify_pass){
|
||||
$admin_data = AdminMaster::where([['email_id', $email], ['pin', $request->digit_pin]])->first();
|
||||
if (empty($admin_data)) {
|
||||
\Log::error("Admin not found with this email id and pin is incorrect.");
|
||||
$msg_data['data'] = array("success" => '0', "message" => "Please enter correct pin!");
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
|
||||
if ($admin_data->is_active == 1) {
|
||||
// \Log::info("Login Successful!");
|
||||
$enc_data = Crypt::encrypt($email);
|
||||
|
||||
//update otp to table
|
||||
$now = Carbon::now('Asia/Kolkata')->format('Y-m-d H:i:s');
|
||||
$otp_data = array();
|
||||
// generateRandomOTP();
|
||||
$otp_data['otp'] = $otp = 1234;
|
||||
$checkOtp = AdminMaster::where('email_id', $email)->first();
|
||||
$update_otp = AdminMaster::find($checkOtp->id);//->update($otp_data);
|
||||
$update_otp->otp = $otp;
|
||||
$update_otp->updated_at = $now;
|
||||
$update_otp->save();
|
||||
|
||||
//send email otp section start
|
||||
$body = $otp;
|
||||
$mail = Mail::send("Admin.Templates.sign_in_otp", ['body'=> $body], function ($message) use ($email) {
|
||||
$message->from('getsetfit@gmail.com', 'GSF');
|
||||
$message->to($email, 'GSF')->subject('Gsf Sign in OTP');
|
||||
});
|
||||
if ($mail){
|
||||
$msg_data['data'] = array("success" => '1', "message" => "OTP has been sent to your mail.", "redirect" => "two_step", "email_id" => $enc_data);
|
||||
return response()->json($msg_data);
|
||||
}else{
|
||||
$msg_data['data'] = array("success" => '0', "message" => "Failed to send OTP. Please try again later.");
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
\Log::error("Account Suspended.");
|
||||
$msg_data['data'] = array("success" => '0', "message" => 'Account is suspended.');
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
$msg_data['data'] = array("success" => '0', "message" => 'Incorrect Password!');
|
||||
return response()->json($msg_data);
|
||||
} catch (\Exception $e) {
|
||||
\Log::error("Login failed: " . $e->getMessage());
|
||||
$msg_data['data'] = array("success" => '0', "message" => 'Something Went Wrong!');
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
}
|
||||
// * Uses : Validates input login request
|
||||
public function validateLogin(Request $request)
|
||||
{
|
||||
return \Validator::make($request->all(),
|
||||
[
|
||||
'email' => 'required|email|string',
|
||||
'password' => 'required|string',
|
||||
'digit_pin' => 'required|digits:4'
|
||||
],
|
||||
[
|
||||
'email.required' => 'Please enter your email.',
|
||||
'password.required' => 'Please enter your password.',
|
||||
'pin.required' => 'Please enter your pin.',
|
||||
'digit_pin.digits' => 'Pin must be 4 digit only.'
|
||||
])->errors();
|
||||
}
|
||||
|
||||
public function verifyLogin(Request $request)
|
||||
{
|
||||
// print_r($request->all);exit;
|
||||
try{
|
||||
$msg_data = array();
|
||||
$validationErrors = $this->validateVerifyLoginRequest($request);
|
||||
if (count($validationErrors)) {
|
||||
\Log::error("Auth Exception: " . implode(", ", $validationErrors->all()));
|
||||
$msg_data['data'] = array("success" => '0', "message" => implode("\n", $validationErrors->all()));
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
|
||||
$email = trim(strtolower(decrypt($request->d)));
|
||||
// print_r($request->otp);
|
||||
// die;
|
||||
// $email = decrypt($request->email);
|
||||
$admin_data = AdminMaster::where([['email_id', $email],['otp', $request->otp]])->first();
|
||||
if(empty($admin_data)){
|
||||
$msg_data['data'] = array("success" => '0', "message" => 'Invalid OTPd.');
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
|
||||
// convert UTc time zone to local
|
||||
$datetime = new DateTime($admin_data->updated_at);
|
||||
$timezone = new DateTimeZone('Asia/Kolkata'); // or whatever zone you're after
|
||||
$datetime->setTimezone($timezone);
|
||||
$update_datetime = $datetime->format('Y-m-d H:i:s');
|
||||
|
||||
//add 5 minut to updated at
|
||||
$minutes_to_add = 5;
|
||||
$time = new DateTime($update_datetime);
|
||||
$time->add(new DateInterval('PT' . $minutes_to_add . 'M'));
|
||||
$timestamp = $time->format('Y-m-d H:i:s');
|
||||
|
||||
//current time
|
||||
$now = Carbon::now('Asia/Kolkata')->format('Y-m-d H:i:s');
|
||||
|
||||
if($admin_data){
|
||||
if($now > $timestamp){
|
||||
$msg_data = array("success" => '0', "message" => 'OTP has been expired.');
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
else{
|
||||
// if(!empty($admin_data)){
|
||||
//creating session if otp is verified
|
||||
$data = array(
|
||||
"id"=>$admin_data->id,
|
||||
"email_id"=>$email,
|
||||
);
|
||||
// print_r($data);
|
||||
// die;
|
||||
// session_start();
|
||||
// $request->session()->put('data',$data);
|
||||
// $sessionDetails = Session::put('data', $data);
|
||||
Session::put('data', $data);
|
||||
$request->session()->put('data',$data);
|
||||
// $sessionDetails= session(['data' => $data]);
|
||||
|
||||
// dd($data,$sessionDetails);
|
||||
// \Session::save();
|
||||
|
||||
// print_r(session('data'));exit;
|
||||
// die;
|
||||
$msg_data['data'] = array("success" => '1', "message" => 'Sign In Successfully.', "redirect" => "dashboard");
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
}else{
|
||||
$msg_data = array("success" => '0', "message" => 'Invalid OTP.');
|
||||
return response()->json($msg_data);
|
||||
}
|
||||
|
||||
}catch (\Exception $e) {
|
||||
\Log::error("Login failed: " . $e->getMessage());
|
||||
return response()->json(array("success" => '0', "message" => 'Something Went Wrong.'));
|
||||
}
|
||||
}
|
||||
|
||||
public function validateVerifyLoginRequest(Request $request)
|
||||
{
|
||||
return \Validator::make($request->all(),
|
||||
[
|
||||
'otp' => 'required|digits:4',
|
||||
],
|
||||
[
|
||||
'otp.required' => 'Please enter 4 digit OTP.',
|
||||
'otp.digits' => 'OTP must be 4 digit.'
|
||||
])->errors();
|
||||
}
|
||||
|
||||
public function adminPostLogin(Request $request)
|
||||
{
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$request->validate([
|
||||
'email' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
$credentials = $request->only('email', 'password');
|
||||
|
||||
$admins = AdminMaster::where('email_id', $request->email)->first();
|
||||
// dd($admins);
|
||||
// $loginInfo = AdminMaster::where('email_id',$request->email)->first();
|
||||
// dd($credentials,Auth::attempt($credentials));
|
||||
// dd(Auth::login($admins));
|
||||
// Auth::attempt(['email_id' => $request->email,'password' => $request->password]);
|
||||
// dd(Auth::attempt(['email_id' => $request->email,'password'=> $request->password]));
|
||||
if ($admins && Auth::guard('admin')->attempt(['email_id' => $request->email,'password'=> $request->password])) {
|
||||
|
||||
|
||||
|
||||
// dd(Auth::guard('admin')->attempt(['email_id' => $request->email,'password'=> $request->password]));
|
||||
$user = Auth::guard('admin')->user();
|
||||
// dd($user);
|
||||
// $token = JWTAuth::fromUser($user); // Generate JWT token for the admin
|
||||
|
||||
// Store the token in the session
|
||||
// Session::put('admin_token', $token);
|
||||
|
||||
|
||||
|
||||
return response(['success'=>true, 'message'=>"You Have Logged in Successfully"]);
|
||||
// ->withHeaders(['X-admin-token' => $token]);
|
||||
|
||||
// return redirect()->intended('dashboard')->withSuccess('You have Successfully logged in');
|
||||
}else{
|
||||
|
||||
return response(['success'=>false, 'message'=>"Invalid! Email or Password "]);
|
||||
}
|
||||
// return redirect()->route('login')->with('error', 'ddddInvalid email or password.');
|
||||
// return redirect("login");
|
||||
}
|
||||
|
||||
}
|
||||
379
app/Http/Controllers/Admin/ManageActivitiesController.php
Normal file
379
app/Http/Controllers/Admin/ManageActivitiesController.php
Normal file
@@ -0,0 +1,379 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ActivityMaster;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use App\Models\ActivitySchedule;
|
||||
use App\Models\ActivityDay;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\ManageFaq;
|
||||
use App\Models\LinkFaqActivityMasterIds;
|
||||
use App\Models\PastSession;
|
||||
use File;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ManageActivitiesController extends Controller {
|
||||
|
||||
public function show_schedule($id) {
|
||||
|
||||
$current_day = Carbon::now()->toDateString();
|
||||
|
||||
$manage_activity_schedule = ActivitySchedule::where('activity_master_id', $id)
|
||||
->where('start_date', '<=',$current_day)
|
||||
->where('end_date', '>=',$current_day)
|
||||
->get()
|
||||
->toArray();
|
||||
// echo "<pre>"; print_r($manage_activity_schedule);exit;
|
||||
return view('Admin.Pages.manage_activities.summer_sweats.summer_sweat')->with(['manage_activity_schedule' => $manage_activity_schedule]);
|
||||
}
|
||||
|
||||
public function show_upcoming_schedule($id) {
|
||||
|
||||
$current_day = Carbon::now()->toDateString();
|
||||
|
||||
$manage_activity_schedule = ActivitySchedule::with('subscription')
|
||||
->where('activity_master_id', $id)
|
||||
->where('end_date', '>=',$current_day)
|
||||
->get()
|
||||
->toArray();
|
||||
// echo "<pre>"; print_r($manage_activity_schedule);exit;
|
||||
return view('Admin.Pages.manage_activities.summer_sweats.upcoming_summer_sweat')->with(['manage_activity_schedule' => $manage_activity_schedule]);
|
||||
}
|
||||
// public function index() {
|
||||
// $add_past_session = PastSession::all()->toArray();
|
||||
//// echo "<pre>"; print_r($add_past_session);exit;
|
||||
// $manage_activity = ActivityMaster::with('subscription','schedule')->get()->toArray();
|
||||
//// echo "<pre>";print_r($manage_activity);exit;
|
||||
// $act_sch = array_column($manage_activity,'schedule');
|
||||
//// echo "<pre>"; print_r($act_sch);exit;
|
||||
// return view('Admin.Pages.manage_activities.manage_activity')->with(['data' => $manage_activity,'act_sch'=>$act_sch,'past_session'=>$add_past_session]);
|
||||
// }
|
||||
|
||||
public function index() {
|
||||
$add_past_session = PastSession::all()->toArray();
|
||||
$currentDate = date('Y-m-d');
|
||||
$schedule_data= [];
|
||||
$manage_upcoming_activity = ActivityMaster::with('subscription', 'schedule')
|
||||
// ->where('start_date', '<=', $currentDate)
|
||||
->where('end_date', '>=', $currentDate)
|
||||
->get()
|
||||
->toArray();
|
||||
$manage_live_activity = ActivityMaster::with('subscription', 'schedule')
|
||||
->where('start_date', '<=', $currentDate)
|
||||
->where('end_date', '>=', $currentDate)
|
||||
->get()
|
||||
->toArray();
|
||||
// $act_sch = array_column($manage_activity, 'schedule');
|
||||
// if($manage_activity){
|
||||
// $activity_master_id = $manage_activity[0]['id'];
|
||||
// $manage_activity_upcomimg = ActivitySchedule::with('subscription')
|
||||
// ->where('activity_master_id',$activity_master_id)
|
||||
// ->where('start_date', '>=' , $currentDate)
|
||||
// ->get()
|
||||
// ->toArray();
|
||||
|
||||
$manage_past_activity = ActivityMaster::with('subscription')
|
||||
->where('start_date','<=',$currentDate)
|
||||
->get()
|
||||
->toArray();
|
||||
// }
|
||||
// echo "<pre>";print_r($manage_activity_past);exit;
|
||||
// $past_data = [];
|
||||
// foreach ($schedule_data as $value){
|
||||
//
|
||||
// $past_data[$value['id']] = PastSession::where('activity_schedule_id',$value['id'])->get()->toArray();
|
||||
//// print_r($past_data);
|
||||
//// exit;
|
||||
//
|
||||
// }
|
||||
// echo '<pre>';print_r($past_data);exit;
|
||||
// echo "<pre>";print_r($manage_activity_upcomimg);exit;
|
||||
return view('Admin.Pages.manage_activities.manage_activity')
|
||||
->with(['data' => $manage_upcoming_activity,'past_session' => $manage_past_activity,'live_data' => $manage_live_activity]);
|
||||
}
|
||||
|
||||
public function insert_main_activity(Request $request) {
|
||||
// echo "<pre>";print_r($request->all());die;
|
||||
// for image upload start
|
||||
// echo "<pre>";
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images';
|
||||
$file->move($path, $file_name);
|
||||
}
|
||||
|
||||
$activity_master = new ActivityMaster;
|
||||
$activity_master->activity_name = $request->input('activity_name');
|
||||
$activity_master->title = $request->input('activity_title');
|
||||
$activity_master->main_activity_banner = url('/public/uploads/activity_banner_images/' . $file_name);
|
||||
$activity_master->description = $request->input('description');
|
||||
$activity_master->start_date = $request->input('start_date');
|
||||
$activity_master->end_date = $request->input('end_date');
|
||||
$activity_master->teacher_id = $request->input('teacher_id');
|
||||
// $activity_master->teaser_url = $request->input('video_teaser_url');
|
||||
$activity_master->benefits = json_encode($request->input('benefits'));
|
||||
$activity_master->pre_requisites = json_encode($request->input('pre_requisites'));
|
||||
$activity_master->subscription_id = $request->input('subscription_id');
|
||||
$activity_master->save();
|
||||
|
||||
// dd($activity_master->id);
|
||||
foreach ($request->input('faq_id') as $faq_id) {
|
||||
$faqs_activity_Ids = new LinkFaqActivityMasterIds;
|
||||
$faqs_activity_Ids->faqs_id = $faq_id;
|
||||
$faqs_activity_Ids->activity_master_id = $activity_master->id;
|
||||
$faqs_activity_Ids->save();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'activity_data' => $activity_master->id,
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
|
||||
public function create_main_activity() {
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
$teacher = Teacher::all()->toArray();
|
||||
$faqs = ManageFaq::all()->toArray();
|
||||
return view('Admin.Pages.manage_activities.add_new_main_activities')->with(['subcriptions' => $subcription, 'teacher' => $teacher, 'faqs' => $faqs,]);
|
||||
}
|
||||
|
||||
public function edit_main_activity($id) {
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
$teacher_data = Teacher::all()->toArray();
|
||||
$faqs_data = ManageFaq::all()->toArray();
|
||||
$get_manage_activity = ActivityMaster::with('faq_activity_link')->where('id', $id)->first()->toArray();
|
||||
$act_faq = array_column($get_manage_activity['faq_activity_link'], 'faqs_id');
|
||||
|
||||
// for benefits
|
||||
$get_manage_activity['benefits_array'] = json_decode($get_manage_activity['benefits']);
|
||||
// for benefits end
|
||||
// for pre_requisites
|
||||
$get_manage_activity['Pre_requisites_array'] = json_decode($get_manage_activity['pre_requisites']);
|
||||
// for pre_requisites end
|
||||
|
||||
|
||||
return view('Admin.Pages.manage_activities.edit_main_activities')->with(['get_manage_activity' => $get_manage_activity, 'subcriptions' => $subcription, 'teacher_datas' => $teacher_data, 'faqs_datas' => $faqs_data, 'act_faq' => $act_faq]);
|
||||
}
|
||||
|
||||
public function edit_upcoming_main_activity($id) {
|
||||
|
||||
// dd($id);
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
$teacher_data = Teacher::all()->toArray();
|
||||
$faqs_data = ManageFaq::all()->toArray();
|
||||
$get_manage_activity = ActivityMaster::with('faq_activity_link')->where('id', $id)->first()->toArray();
|
||||
$act_faq = array_column($get_manage_activity['faq_activity_link'], 'faqs_id');
|
||||
|
||||
// for benefits
|
||||
$get_manage_activity['benefits_array'] = json_decode($get_manage_activity['benefits']);
|
||||
// for benefits end
|
||||
// for pre_requisites
|
||||
$get_manage_activity['Pre_requisites_array'] = json_decode($get_manage_activity['pre_requisites']);
|
||||
// for pre_requisites end
|
||||
|
||||
|
||||
return view('Admin.Pages.manage_activities.edit_upcoming_main_activities')->with(['get_manage_activity' => $get_manage_activity, 'subcriptions' => $subcription, 'teacher_datas' => $teacher_data, 'faqs_datas' => $faqs_data, 'act_faq' => $act_faq]);
|
||||
}
|
||||
|
||||
public function update_main_activity(Request $request) {
|
||||
|
||||
// echo "<pre>";print_r($request->all());
|
||||
$activity_master_id = $request->edit_main_activity_id;
|
||||
$link_master_id = LinkFaqActivityMasterIds::where('activity_master_id', $request->edit_main_activity_id)->delete();
|
||||
|
||||
foreach ($request->input('faq_id') as $faq_id) {
|
||||
$faqs_activity_Ids = new LinkFaqActivityMasterIds;
|
||||
$faqs_activity_Ids->faqs_id = $faq_id;
|
||||
$faqs_activity_Ids->activity_master_id = $request->edit_main_activity_id;
|
||||
$faqs_activity_Ids->save();
|
||||
}
|
||||
if ($request->main_activity_banner) {
|
||||
$rules = [
|
||||
'main_activity_banner' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false, 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('main_activity_banner');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/';
|
||||
$file->move($path, $file_name);
|
||||
$file_name_store = url('/public/uploads/activity_banner_images/' . $file_name);
|
||||
}
|
||||
// print_r($file_name_store);
|
||||
// exit;
|
||||
} else {
|
||||
$file_name_store = $request->db_image;
|
||||
}
|
||||
// dd($file_name_store);
|
||||
$activity_master = ActivityMaster::find($request->edit_main_activity_id);
|
||||
$activity_master->activity_name = $request->input('activity_name');
|
||||
$activity_master->title = $request->input('activity_title');
|
||||
$activity_master->description = $request->input('description');
|
||||
$activity_master->start_date = $request->input('start_date');
|
||||
$activity_master->end_date = $request->input('end_date');
|
||||
$activity_master->teacher_id = $request->input('teacher_id');
|
||||
$activity_master->subscription_id = $request->input('subscription_id');
|
||||
$activity_master->benefits = $request->input('benefits');
|
||||
$activity_master->pre_requisites = $request->input('pre_requisites');
|
||||
$activity_master->main_activity_banner = $file_name_store;
|
||||
$activity_master->save();
|
||||
|
||||
ActivitySchedule::where('activity_master_id',$request->edit_main_activity_id)->update(['subscription_id'=>$request->input('subscription_id')]);
|
||||
ActivityDay::where('activity_master_id',$request->edit_main_activity_id)->update(['subscription_id'=>$request->input('subscription_id')]);
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
|
||||
public function update_upcoming_main_activity(Request $request) {
|
||||
|
||||
// echo "<pre>";print_r($request->all());
|
||||
$activity_master_id = $request->edit_main_activity_id;
|
||||
$link_master_id = LinkFaqActivityMasterIds::where('activity_master_id', $request->edit_main_activity_id)->delete();
|
||||
|
||||
foreach ($request->input('faq_id') as $faq_id) {
|
||||
$faqs_activity_Ids = new LinkFaqActivityMasterIds;
|
||||
$faqs_activity_Ids->faqs_id = $faq_id;
|
||||
$faqs_activity_Ids->activity_master_id = $request->edit_main_activity_id;
|
||||
$faqs_activity_Ids->save();
|
||||
}
|
||||
if ($request->main_activity_banner) {
|
||||
$file = $request->file('main_activity_banner');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/';
|
||||
$file->move($path, $file_name);
|
||||
$file_name_store = url('/public/uploads/activity_banner_images/' . $file_name);
|
||||
// print_r($file_name_store);
|
||||
// exit;
|
||||
} else {
|
||||
$file_name_store = $request->db_image;
|
||||
}
|
||||
// dd($file_name_store);
|
||||
$activity_master = ActivityMaster::find($request->edit_main_activity_id);
|
||||
$activity_master->activity_name = $request->input('activity_name');
|
||||
$activity_master->title = $request->input('activity_title');
|
||||
$activity_master->description = $request->input('description');
|
||||
$activity_master->start_date = $request->input('start_date');
|
||||
$activity_master->end_date = $request->input('end_date');
|
||||
$activity_master->teacher_id = $request->input('teacher_id');
|
||||
$activity_master->subscription_id = $request->input('subscription_id');
|
||||
$activity_master->teaser_url = $request->input('video_teaser_url');
|
||||
$activity_master->benefits = $request->input('benefits');
|
||||
$activity_master->pre_requisites = $request->input('pre_requisites');
|
||||
$activity_master->main_activity_banner = $file_name_store;
|
||||
$activity_master->save();
|
||||
|
||||
ActivitySchedule::where('activity_master_id',$request->edit_main_activity_id)->update(['subscription_id'=>$request->input('subscription_id')]);
|
||||
ActivityDay::where('activity_master_id',$request->edit_main_activity_id)->update(['subscription_id'=>$request->input('subscription_id')]);
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
|
||||
public function delete_main_activity($id) {
|
||||
$manage_activity = ActivityMaster::find($id)->delete();
|
||||
if($manage_activity){
|
||||
ActivitySchedule::where('activity_master_id',$id)->delete();
|
||||
ActivityDay::where('activity_master_id',$id)->delete();
|
||||
}
|
||||
|
||||
return response()->json(['success' => true,'status' => 200]);
|
||||
}
|
||||
|
||||
public function edit_past_session($id) {
|
||||
$pass_session = PastSession::find($id)->toArray();
|
||||
// echo '<pre>';print_r($pass_session);exit;
|
||||
return view('Admin.Pages.manage_activities.past_session.edit_past_session')->with(['get_pass_session' => $pass_session]);
|
||||
}
|
||||
|
||||
public function update(Request $request) {
|
||||
// echo "<pre>";
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$currentDate = date('Y-m-d');
|
||||
$past_session = $request->past_id;
|
||||
$past_schedule_id = $request->schedule_id;
|
||||
// print_r($past_schedule_id);
|
||||
// exit;
|
||||
$past_session = PastSession::find($request->past_id);
|
||||
|
||||
if ($request->hasFile('myFile')) {
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$path = public_path() . '/uploads/past_session';
|
||||
File::delete($path . $past_session->image);
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name_main_image_old = time() . '.' . $ext;
|
||||
$file_name_main_image = url('/public/uploads/past_session/' . $file_name_main_image_old);
|
||||
$file->move($path, $file_name_main_image);
|
||||
}
|
||||
} else {
|
||||
$file_name_main_image = $request->input('db_image');
|
||||
}
|
||||
|
||||
// for image upload end
|
||||
$past_session->activity_name = $request->input('activity_name');
|
||||
$past_session->url = $request->input('video_teaser_url');
|
||||
$past_session->image = $file_name_main_image;
|
||||
$past_session->duration = $request->input('activity_duration');
|
||||
$past_session->date = $request->input('date');
|
||||
$past_session->day = $request->input('day');
|
||||
|
||||
$date = strtotime($request->input('date'));
|
||||
if ($date <= $currentDate) {
|
||||
$past_session->save();
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200,'id' => $past_schedule_id]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Date is not greter than current date.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_past_session($id) {
|
||||
$past_session = PastSession::find($id)->delete();
|
||||
}
|
||||
|
||||
}
|
||||
37
app/Http/Controllers/Admin/ManageBannerController.php
Normal file
37
app/Http/Controllers/Admin/ManageBannerController.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManageBannerService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageBanner;
|
||||
|
||||
|
||||
class ManageBannerController extends Controller
|
||||
{
|
||||
public function __construct(ManageBannerService $manageBannerService)
|
||||
{
|
||||
$this->manageBannerService = $manageBannerService;
|
||||
}
|
||||
|
||||
public function create(){
|
||||
$get_manage_banner['get_single_banner'] = $this->manageBannerService->view_manage_banner()->toArray();
|
||||
// dd($get_manage_banner);
|
||||
$manage_banner = $this->manageBannerService->view_manage_banner()->toArray();
|
||||
return view('Admin.Pages.manage_cms.banner.manage_cms_banner', $get_manage_banner);
|
||||
}
|
||||
|
||||
public function insert_manage_bannner(Request $request)
|
||||
{
|
||||
$manage_banner = $this->manageBannerService->insert_manage_bannner($request);
|
||||
if(!empty($manage_banner)){
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
return response()->json(['success' => true, 'status'=>200]);
|
||||
}
|
||||
|
||||
}
|
||||
16
app/Http/Controllers/Admin/ManageCmsController.php
Normal file
16
app/Http/Controllers/Admin/ManageCmsController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageCmsController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_cms.manage_cms');
|
||||
}
|
||||
public function manage_cms_upload(){
|
||||
return view('Admin.Pages.manage_cms.manage_cms_upload');
|
||||
}
|
||||
}
|
||||
223
app/Http/Controllers/Admin/ManageCmsNewsAndArticleController.php
Normal file
223
app/Http/Controllers/Admin/ManageCmsNewsAndArticleController.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageNewsArticles;
|
||||
use App\Models\NewsArticlesCategory;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ManageCmsNewsAndArticleController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
|
||||
$data['category'] = NewsArticlesCategory::with('articles')->get();
|
||||
// dd($data);
|
||||
$data['article'] = ManageNewsArticles::all();
|
||||
|
||||
return view('Admin.Pages.manage_cms.news_and_articles.manage_cms_news_article',$data);
|
||||
}
|
||||
public function add_manage_cms_news_article(){
|
||||
$data['category'] = NewsArticlesCategory::all();
|
||||
return view('Admin.Pages.manage_cms.news_and_articles.add_news_article',$data);
|
||||
}
|
||||
public function edit_manage_cms_news_article($id){
|
||||
|
||||
$data['category'] = NewsArticlesCategory::get();
|
||||
$data['article'] = ManageNewsArticles::where('id',$id)->first();
|
||||
// dd($data);
|
||||
return view('Admin.Pages.manage_cms.news_and_articles.edit_news_and_articles',$data);
|
||||
}
|
||||
|
||||
//Category Start from here
|
||||
public function addCategoriesData(Request $request){
|
||||
|
||||
// dd($request->all());
|
||||
$category = NewsArticlesCategory::create(['category_name'=>$request->categoryName]);
|
||||
if($category){
|
||||
return response()->json([
|
||||
'messages' => "Categories Is Added Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editCategoriesData(Request $request){
|
||||
|
||||
$updatecategory = NewsArticlesCategory::where('id',$request->editCatId)->update(['category_name'=>$request->editCatName]);
|
||||
if($updatecategory){
|
||||
return response()->json([
|
||||
'messages' => "Categories Is Updated Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCategoriesData(Request $request){
|
||||
|
||||
$deleteCat = NewsArticlesCategory::where('id',$request->deleteId)->delete();
|
||||
if($deleteCat){
|
||||
return response()->json([
|
||||
'messages' => "Category Is Deleted successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
|
||||
public function updatCatStatus(Request $request){
|
||||
|
||||
$status = NewsArticlesCategory::where('id',$request->catId)->update(['is_active'=> $request->status]);
|
||||
return response()->json([
|
||||
'messages' => "Status Updated Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
|
||||
}
|
||||
//Category End from here
|
||||
|
||||
//Article Starts Here
|
||||
|
||||
public function addArticleData(Request $request){
|
||||
|
||||
$addArticle = new ManageNewsArticles;
|
||||
// $rules = [
|
||||
// 'articleThumbnailImage' => 'required|file|max:1000', // 400 KB
|
||||
// ];
|
||||
|
||||
// $validator = Validator::make($request->all(),$rules);
|
||||
|
||||
// if ($validator->fails()) {
|
||||
// if ($request->expectsJson()) {
|
||||
// return response()->json(['success' => false , 'status' => 422,'message'=>'Image should be Less Than 1 MB']);
|
||||
// }
|
||||
// }else {
|
||||
// $file = $request->file('articleThumbnailImage');
|
||||
// $ext = $file->extension();
|
||||
// $file_name = time() . '.' . $ext;
|
||||
// $path = public_path() . '/uploads/news_articles/thumbnail_image';
|
||||
// $file->move($path, $file_name);
|
||||
// $addArticle->thumbnail_path = url('/public/uploads/news_articles/thumbnail_image/' . $file_name);
|
||||
// }
|
||||
|
||||
$rules = [
|
||||
'articleImage' => 'required|file|max:1000', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422,'message'=>'Image should be Less Than 1 MB']);
|
||||
}
|
||||
}else {
|
||||
$file = $request->file('articleImage');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/news_articles/image';
|
||||
$file->move($path, $file_name);
|
||||
$addArticle->image_upload = url('/public/uploads/news_articles/image/' . $file_name);
|
||||
}
|
||||
|
||||
$addArticle->category_id = $request->articleCatId;
|
||||
$addArticle->article_name = $request->articleName;
|
||||
$addArticle->short_text = $request->articleShortText;
|
||||
$addArticle->description = $request->articleDescription;
|
||||
|
||||
// $addArticle->video_url = $request->articleUrl;
|
||||
// $addArticle->tags = $request->articleTags;
|
||||
$addArticle->save();
|
||||
if($addArticle){
|
||||
return response()->json([
|
||||
'messages' => "Article Added Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
|
||||
public function editArticleData(Request $request){
|
||||
|
||||
// dd($request->all());
|
||||
$editArticle = ManageNewsArticles::find($request->articleId);
|
||||
// dd($editArticle);
|
||||
// if($request->file('articleThumbnailImage')){
|
||||
// $rules = [
|
||||
// 'articleThumbnailImage' => 'required|file|max:1000', // 400 KB
|
||||
// ];
|
||||
|
||||
// $validator = Validator::make($request->all(),$rules);
|
||||
|
||||
// if ($validator->fails()) {
|
||||
// if ($request->expectsJson()) {
|
||||
// return response()->json(['success' => false , 'status' => 422,'message'=>'Image should be Less Than 2 MB']);
|
||||
// }
|
||||
// }else {
|
||||
// $file = $request->file('articleThumbnailImage');
|
||||
// $ext = $file->extension();
|
||||
// $file_name = time() . '.' . $ext;
|
||||
// $path = public_path() . '/uploads/news_articles/thumbnail_image';
|
||||
// $file->move($path, $file_name);
|
||||
// $editArticle->thumbnail_path = url('/public/uploads/news_articles/thumbnail_image/' . $file_name);
|
||||
// }
|
||||
// }
|
||||
if($request->file('articleImage')){
|
||||
$rules = [
|
||||
'articleImage' => 'required|file|max:1000', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422,'message'=>'Image should be Less Than 1 MB']);
|
||||
}
|
||||
}else {
|
||||
$file = $request->file('articleImage');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/news_articles/image';
|
||||
$file->move($path, $file_name);
|
||||
$editArticle->image_upload = url('/public/uploads/news_articles/image/' . $file_name);
|
||||
}
|
||||
}
|
||||
$editArticle->category_id = $request->articleCatId;
|
||||
$editArticle->article_name = $request->articleName;
|
||||
$editArticle->short_text = $request->articleShortText;
|
||||
$editArticle->description = $request->articleDescription;
|
||||
|
||||
// $editArticle->video_url = $request->articleUrl;
|
||||
// $editArticle->tags = $request->articleTags;
|
||||
$editArticle->save();
|
||||
if($editArticle){
|
||||
return response()->json([
|
||||
'messages' => "Article Added Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
|
||||
public function updatArticleStatus(Request $request){
|
||||
|
||||
// dd($request->all());
|
||||
$status = ManageNewsArticles::where('id',$request->catId)->update(['is_active'=> $request->status]);
|
||||
return response()->json([
|
||||
'messages' => "Status Updated Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function deleteArticlesData(Request $request){
|
||||
|
||||
$deleteCat = ManageNewsArticles::where('id',$request->deleteId)->delete();
|
||||
if($deleteCat){
|
||||
return response()->json([
|
||||
'messages' => "Category Is Deleted successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
//Article ends Here
|
||||
}
|
||||
27
app/Http/Controllers/Admin/ManageCompanyUserController.php
Normal file
27
app/Http/Controllers/Admin/ManageCompanyUserController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageCompanyUserController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_company_users.manage_company_user');
|
||||
}
|
||||
public function create_add_company(){
|
||||
return view('Admin.Pages.manage_company_users.add_company');
|
||||
}
|
||||
public function create_company_user(){
|
||||
return view('Admin.Pages.manage_company_users.add_company_user');
|
||||
}
|
||||
public function index(){
|
||||
return view('Admin.Pages.manage_company_users.company');
|
||||
}
|
||||
public function index_user_profile_three(){
|
||||
return view('Admin.Pages.manage_company_users.users_profile_three');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
52
app/Http/Controllers/Admin/ManageContactController.php
Normal file
52
app/Http/Controllers/Admin/ManageContactController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManageContactService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ContactUs;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\UsersExport;
|
||||
|
||||
class ManageContactController extends Controller {
|
||||
|
||||
public function __construct(ManageContactService $manageContactService) {
|
||||
$this->manageContactService = $manageContactService;
|
||||
}
|
||||
|
||||
public function create() {
|
||||
return view('Admin.Pages.manage_contact.manage_contact');
|
||||
}
|
||||
|
||||
public function view_contact(Request $req) {
|
||||
$manage_contact = $this->manageContactService->view_contact();
|
||||
return view('Admin.Pages.manage_contact.manage_contact')->with(['manage_contact' => $manage_contact]);
|
||||
}
|
||||
|
||||
public function deleted(Request $request) {
|
||||
$deleted_contact = $this->manageContactService->delete_contact();
|
||||
return view('Admin.Pages.manage_contact.manage_contact_deleted')->with(['deleted_contact' => $deleted_contact]);
|
||||
}
|
||||
|
||||
public function delete_contact($id) {
|
||||
ContactUs::find($id)->delete();
|
||||
}
|
||||
|
||||
public function sendManageContact(Request $request) {
|
||||
|
||||
$contact = $this->manageContactService->send_mail($request);
|
||||
return response()->json([
|
||||
'status' => 200
|
||||
]);
|
||||
}
|
||||
|
||||
public function exportUser()
|
||||
{
|
||||
// return Excel::download(new UsersExport, 'users.xlsx');
|
||||
// return Excel::download(new UsersExport, 'user.xlsx', \Maatwebsite\Excel\Excel::XLSX);
|
||||
// return Excel::download(new UsersExport, 'user.xlsx');
|
||||
return Excel::download(new UsersExport, 'user.xlsx');
|
||||
|
||||
}
|
||||
}
|
||||
155
app/Http/Controllers/Admin/ManageDietPlanController.php
Normal file
155
app/Http/Controllers/Admin/ManageDietPlanController.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManageDietPlanService;
|
||||
use App\Models\DietPlan;
|
||||
use Illuminate\Http\Request;
|
||||
use File;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ManageDietPlanController extends Controller
|
||||
{
|
||||
// public function create(){
|
||||
// return view('Admin.Pages.manage_diet_plans.manage_diet_plan');
|
||||
// }
|
||||
|
||||
public function __construct(ManageDietPlanService $manageDietPlanService) {
|
||||
$this->manageDietPlanService = $manageDietPlanService;
|
||||
}
|
||||
|
||||
public function create(Request $req) {
|
||||
$manage_diet_plan = $this->manageDietPlanService->create();
|
||||
// echo "<pre>"; print_r($manage_diet_plan);exit;
|
||||
return view('Admin.Pages.manage_diet_plans.manage_diet_plan')->with(['manage_diet_plan' => $manage_diet_plan]);
|
||||
}
|
||||
|
||||
public function create_diet_plan()
|
||||
{
|
||||
return view('Admin.Pages.manage_diet_plans.add_diet_plan');
|
||||
}
|
||||
|
||||
public function insert_diet_plan(Request $request)
|
||||
{
|
||||
$dietCategories = $request->input('diet_categories');
|
||||
$bmrRangeFrom = $request->input('bmr_range_from');
|
||||
$bmrRangeTo = $request->input('bmr_range_to');
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:2048', // 2048 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// Validate input if necessary
|
||||
|
||||
$oldDietPlan = DietPlan::where('diet_categories', $dietCategories)
|
||||
->where('bmr_range_from', $bmrRangeFrom)
|
||||
->where('bmr_range_to', $bmrRangeTo)
|
||||
->exists();
|
||||
// dd($oldDietPlan);
|
||||
if ($oldDietPlan == true) {
|
||||
return response()->json(['success' => false, 'status' => 403]);
|
||||
}else{
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/diet_plan';
|
||||
$file->move($path, $file_name);
|
||||
|
||||
// for image upload end
|
||||
|
||||
$add_diet_plan = new DietPlan;
|
||||
$add_diet_plan->image = url('/public/uploads/diet_plan/'.$file_name);
|
||||
$add_diet_plan->diet_categories = $request->input('diet_categories');
|
||||
$add_diet_plan->bmr_range_from = $request->input('bmr_range_from');
|
||||
$add_diet_plan->bmr_range_to = $request->input('bmr_range_to');
|
||||
|
||||
$add_diet_plan->save();
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function edit_diet_plan($id)
|
||||
{
|
||||
$diet_plan = DietPlan::find($id)->toArray();
|
||||
return view('Admin.Pages.manage_diet_plans.edit_diet_plan')->with(['get_diet_plan' => $diet_plan]);
|
||||
}
|
||||
|
||||
// public function update_diet_plan(Request $request)
|
||||
// {
|
||||
// $diet_plan = $request->diet_id;
|
||||
// $diet_plan = DietPlan::find($request->id);
|
||||
//
|
||||
// if ($request->hasFile('image')) {
|
||||
// $path = public_path() . '/uploads/diet_plan';
|
||||
// $file = $request->file('image');
|
||||
// $ext = $file->extension();
|
||||
// $file_name_main_image = time() . '.' . $ext;
|
||||
// $file->move($path, $file_name_main_image);
|
||||
// } else {
|
||||
// $file_name_main_image = $diet_plan->image;
|
||||
// }
|
||||
//
|
||||
// // for image upload end
|
||||
//
|
||||
// $update_diet_plan->image = url('/public/uploads/diet_plan/'.$file_name_main_image);
|
||||
// $update_diet_plan->diet_categories = $request->input('diet_categories');
|
||||
// $update_diet_plan->bmr_range_from = $request->input('bmr_range_from');
|
||||
// $update_diet_plan->bmr_range_to = $request->input('bmr_range_to');
|
||||
// $update_diet_plan->save();
|
||||
//
|
||||
// return response()->json(['success' => true, 'status' => 200]);
|
||||
// }
|
||||
//
|
||||
public function update_diet_plan(Request $request) {
|
||||
// dd($request);
|
||||
if($request->image){
|
||||
$rules = [
|
||||
'image' => 'required|file|max:2048', // 2048 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$file = $request->file('image');
|
||||
// print_r($file); exit;
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/diet_plan';
|
||||
$file->move($path, $file_name);
|
||||
$image_name = url('/public/uploads/diet_plan/'.$file_name);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$image_name=$request->db_image;
|
||||
}
|
||||
|
||||
$dietPlanId = $request->diet_id;
|
||||
$update_diet_plan = DietPlan::find($request->diet_id);
|
||||
$update_diet_plan->diet_categories = $request->input('diet_categories');
|
||||
$update_diet_plan->bmr_range_from = $request->input('bmr_range_from');
|
||||
$update_diet_plan->bmr_range_to = $request->input('bmr_range_to');
|
||||
$update_diet_plan->image = $image_name;
|
||||
$update_diet_plan->save();
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
|
||||
public function delete_diet_plan($id) {
|
||||
$delete_diet_plan = DietPlan::find($id)->delete();
|
||||
}
|
||||
}
|
||||
60
app/Http/Controllers/Admin/ManageDirectUserController.php
Normal file
60
app/Http/Controllers/Admin/ManageDirectUserController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDetail;
|
||||
use App\Models\LeaderboardMaster;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use App\Models\ShortClipsLikes;
|
||||
|
||||
class ManageDirectUserController extends Controller
|
||||
{
|
||||
public function view_users(){
|
||||
$data = User::with('user_detail')->get()->toArray();
|
||||
return view('Admin.Pages.manage_direct_users.manage_direct_users')->with(['user_data'=> $data]);
|
||||
}
|
||||
public function index(){
|
||||
return view('Admin.Pages.manage_direct_users.users-profile-two');
|
||||
}
|
||||
|
||||
public function edit_user($id){
|
||||
|
||||
$get_single_user = User::with('user_detail')
|
||||
->where('id', $id)
|
||||
->first()
|
||||
->toArray();
|
||||
// dd($get_single_user);
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
return view('Admin.Pages.manage_direct_users.users-profile-two')->with(['get_single_user_data'=> $get_single_user , 'subcriptions' => $subcription]);;
|
||||
}
|
||||
|
||||
public function destroy_user($id){
|
||||
// dd($id);
|
||||
ShortClipsLikes::where('user_id',$id)->delete();
|
||||
$delete_user = User::find($id)->delete();
|
||||
LeaderboardMaster::where('user_id',$id)->delete();
|
||||
return response()->json(['success' => true,'status' => 200]);
|
||||
}
|
||||
|
||||
public function update_age_height(Request $request){
|
||||
// dd($request->all());
|
||||
|
||||
UserDetail::where('user_id',$request->user_id)->update(['age'=>$request->age,'height'=>$request->height]);
|
||||
return response()->json(['success' => true,'status' => 200]);
|
||||
}
|
||||
|
||||
public function updateSubPlan(Request $request){
|
||||
|
||||
// dd($request->id);
|
||||
$data = User::where('id', $request->id)->update(['utm_source' => $request->data]);
|
||||
if($data == 1){
|
||||
return response()->json(['success' => true,'status' => 200]);
|
||||
}else{
|
||||
return response()->json(['success' => true,'status' => 500]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
99
app/Http/Controllers/Admin/ManageFaqController.php
Normal file
99
app/Http/Controllers/Admin/ManageFaqController.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManageFaqService;
|
||||
use App\Models\ManageFaqCategory;
|
||||
use App\Models\ManageFaq;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageFaqController extends Controller
|
||||
{
|
||||
public function __construct(ManageFaqService $manageFaqService)
|
||||
{
|
||||
$this->manageFaqService = $manageFaqService;
|
||||
}
|
||||
|
||||
// public function create(){
|
||||
// return view('Admin.Pages.manage_cms.manage_faq.manage_faqs');
|
||||
// }
|
||||
|
||||
public function insert_faq_categories(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
$faq_categories = $this->manageFaqService->insert_faq_categories($request);
|
||||
return response()->json(['success' => true,'status'=>200]);
|
||||
|
||||
}
|
||||
|
||||
public function view_faq_category()
|
||||
{
|
||||
$faq_categories['faq_categories'] = $this->manageFaqService->view_faq_category();
|
||||
$faq['faq'] = $this->manageFaqService->view_faq();
|
||||
|
||||
// echo "<pre>";
|
||||
// print_r($faq_categories);
|
||||
// print_r($faq);
|
||||
// echo "</pre>";
|
||||
// exit;
|
||||
return view('Admin.Pages.manage_cms.manage_faq.manage_faqs',$faq_categories,$faq);
|
||||
}
|
||||
|
||||
public function delete_faq_category($id)
|
||||
{
|
||||
$faq_categories = ManageFaqCategory::find($id)->delete();
|
||||
}
|
||||
|
||||
public function update_faq_category(Request $request)
|
||||
{
|
||||
$faq_categories = $this->manageFaqService->update_faq_categories($request);
|
||||
return response()->json(['success2' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
public function change_faq_catg_Status_(Request $request)
|
||||
{
|
||||
// dd($request->faq_catag_id);
|
||||
$status = ManageFaqCategory::find($request->faq_catag_id);
|
||||
$status->is_active = $request->status;
|
||||
$status->save();
|
||||
return response()->json(['success'=>'Status change successfully.']);
|
||||
|
||||
}
|
||||
|
||||
// =================================================================================================================
|
||||
|
||||
public function insert_faq(Request $request)
|
||||
{
|
||||
$faq_categories = ManageFaqCategory::all();
|
||||
|
||||
$faq = $this->manageFaqService->insert_faq($request);
|
||||
|
||||
return response()->json(['success' => true, 'status'=>200, 'faq_categories'=>$faq_categories]);
|
||||
|
||||
}
|
||||
|
||||
public function delete_faq($id)
|
||||
{
|
||||
$faq = ManageFaq::find($id)->delete();
|
||||
}
|
||||
|
||||
public function update_faq(Request $request)
|
||||
{
|
||||
$faq_categories = $this->manageFaqService->update_faq($request);
|
||||
return response()->json(['success' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
|
||||
public function change_faq_Status(Request $request)
|
||||
{
|
||||
// dd($request->faq_catag_id);
|
||||
$status = ManageFaq::find($request->faq_id);
|
||||
$status->is_active = $request->status;
|
||||
$status->save();
|
||||
return response()->json(['success'=>'Status change successfully.']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
24
app/Http/Controllers/Admin/ManageFeedbackController.php
Normal file
24
app/Http/Controllers/Admin/ManageFeedbackController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageFeedback;
|
||||
use App\Models\User;
|
||||
use App\Models\AppVersion;
|
||||
use App\Models\UserDetail;
|
||||
|
||||
class ManageFeedbackController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
$feedback = ManageFeedback::with('user','user_detail')->where('is_active','0')->get();
|
||||
// dd($feedback);
|
||||
return view('Admin.Pages.manage_feedback.manage_feedback',compact('feedback'));
|
||||
}
|
||||
|
||||
public function delete_feedback($id){
|
||||
$data = ManageFeedback::find($id)->delete();
|
||||
// dd($data);
|
||||
}
|
||||
}
|
||||
41
app/Http/Controllers/Admin/ManageNotificationController.php
Normal file
41
app/Http/Controllers/Admin/ManageNotificationController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Models\NotificationMaster;
|
||||
use App\Models\NotificationUser;
|
||||
|
||||
class ManageNotificationController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_notification.manage_notification');
|
||||
}
|
||||
|
||||
public function send_notification(Request $request){
|
||||
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$user = User::get();
|
||||
|
||||
// NotificationMaster::create[]
|
||||
$notification_master = new NotificationMaster;
|
||||
$notification_master->title = $request->title;
|
||||
$notification_master->messages = $request->message;
|
||||
$notification_master->save();
|
||||
|
||||
$notification_id = $notification_master->id;
|
||||
|
||||
foreach ($user as $user_data){
|
||||
|
||||
$notification_user = new NotificationUser;
|
||||
$notification_user->notification_id = $notification_id;
|
||||
$notification_user->user_id = $user_data->id;
|
||||
$notification_user->save();
|
||||
}
|
||||
|
||||
return response()->json(['success' => true,'status' => 200]);
|
||||
}
|
||||
}
|
||||
116
app/Http/Controllers/Admin/ManagePastSessionContoller.php
Normal file
116
app/Http/Controllers/Admin/ManagePastSessionContoller.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\PastSession;
|
||||
use App\Models\ActivityMaster;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use App\Models\ActivitySchedule;
|
||||
use App\Models\ActivityDay;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\ManageFaq;
|
||||
use App\Models\LinkFaqActivityMasterIds;
|
||||
use File;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ManagePastSessionContoller extends Controller
|
||||
{
|
||||
|
||||
public function past_schedule($id){
|
||||
|
||||
$currentDate = date('Y-m-d');
|
||||
$manage_past_activity = ActivitySchedule::with('subscription')
|
||||
->where('activity_master_id',$id)
|
||||
->where('start_date','<=',$currentDate)
|
||||
->orderBy('start_date', 'DESC')
|
||||
->get()
|
||||
->toArray();
|
||||
return view('Admin.Pages.manage_activities.past_session.past_schedules')->with(['manage_activity_schedule' => $manage_past_activity]);
|
||||
}
|
||||
public function create_past_session($id)
|
||||
{
|
||||
// print_r($id);
|
||||
// exit;
|
||||
|
||||
$get_single_activity = ActivitySchedule::find($id)->toArray();
|
||||
// echo "<pre>"; print_r($get_single_activity);exit;
|
||||
return view('Admin.Pages.manage_activities.past_session.add_past_session')->with(['get_data' => $get_single_activity]);
|
||||
// return view('Admin.Pages.manage_activities.past_session.add_past_session');
|
||||
}
|
||||
|
||||
public function insert_past_session(Request $request)
|
||||
{
|
||||
// echo '<pre>';
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$currentDate = date('Y-m-d');
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/past_session';
|
||||
$file->move($path, $file_name);
|
||||
}
|
||||
// for image upload end
|
||||
|
||||
$add_past_session = new PastSession;
|
||||
$add_past_session->activity_master_id = $request->input('activity_id');
|
||||
$add_past_session->activity_schedule_id = $request->input('schedule_id');
|
||||
$add_past_session->activity_name = $request->input('activity_name');
|
||||
$add_past_session->url = $request->input('video_teaser_url');
|
||||
$add_past_session->duration = $request->input('activity_duration');
|
||||
$add_past_session->image = url('/public/uploads/past_session/'.$file_name);
|
||||
$add_past_session->date = $request->input('date');
|
||||
$add_past_session->day = $request->input('day');
|
||||
|
||||
$date = strtotime($request->input('date'));
|
||||
// Retrieve the ActivityMaster record
|
||||
// $activity_schedule = ActivitySchedule::find($request->input('schedule_id'));
|
||||
|
||||
// $activity_shedule_start_date = strtotime($activity_schedule->start_date);
|
||||
// $activity_shedule_end_date = strtotime($activity_schedule->end_date);
|
||||
if ($date <= $currentDate) {
|
||||
$add_past_session->save();
|
||||
|
||||
return response()->json(['success' => true, 'status' => 200,'id' =>$request->input('schedule_id')]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Date is not greter than current date.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function past_days_show($id){
|
||||
|
||||
// print_r($id);
|
||||
// exit;
|
||||
$current_day = now()->format('Y-m-d');
|
||||
$past_data = PastSession::where('activity_schedule_id',$id)
|
||||
->where('date','<=',$current_day)
|
||||
->get()
|
||||
->toArray();
|
||||
// echo '<pre>';
|
||||
// print_r($past_data);
|
||||
// exit;
|
||||
return view('Admin.Pages.manage_activities.past_session.past_activity_day')->with(['manage_activity_day' => $past_data]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
61
app/Http/Controllers/Admin/ManagePlanController.php
Normal file
61
app/Http/Controllers/Admin/ManagePlanController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManagePlanService;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use App\Models\SubscriptionPlanPackage;
|
||||
use App\Models\SubscriptionPackageDescription;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagePlanController extends Controller
|
||||
{
|
||||
|
||||
public function __construct(ManagePlanService $managePlanService) {
|
||||
$this->managePlanService = $managePlanService;
|
||||
}
|
||||
|
||||
public function view_plan(Request $req) {
|
||||
$manage_plan = $this->managePlanService->view_plan();
|
||||
// echo "<pre>"; print_r($manage_plan);exit;
|
||||
return view('Admin.Pages.manage_plan.manage_plan')->with(['manage_plan' => $manage_plan]);
|
||||
}
|
||||
|
||||
public function create_plan() {
|
||||
return view('Admin.Pages.manage_plan.add_plan');
|
||||
}
|
||||
|
||||
public function insert_plan(Request $request)
|
||||
{
|
||||
try {
|
||||
$plan = $this->managePlanService->insert_plan($request);
|
||||
return response()->json(['status' => 200, 'message' => 'Plan added successfully']);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = $this->managePlanService->edit_plan($id);
|
||||
return view('Admin.Pages.manage_plan.edit_plan')->with(['plan_data'=>$data]);
|
||||
}
|
||||
|
||||
public function delete_plan($id) {
|
||||
// print_r($id);die;
|
||||
$plan = SubscriptionMaster::find($id)->delete();
|
||||
$plan = SubscriptionPlanPackage::where('subscription_master_id', $id)->delete();
|
||||
$plan = SubscriptionPackageDescription::where('subscription_master_id', $id)->delete();
|
||||
|
||||
}
|
||||
|
||||
public function update_plan(Request $request)
|
||||
{
|
||||
$plan_update = $this->managePlanService->update_plan($request);
|
||||
return response()->json(['success' => true,'status'=>200]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
144
app/Http/Controllers/Admin/ManagePodcastController.php
Normal file
144
app/Http/Controllers/Admin/ManagePodcastController.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManagePodcast;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ManagePodcastController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
$data['podcast'] = ManagePodcast::latest()->get();
|
||||
// dd($data['podcast']);
|
||||
return view('Admin.Pages.manage_cms.manage_podcast.manage_podcast',$data);
|
||||
}
|
||||
public function add_manage_podcast(){
|
||||
return view('Admin.Pages.manage_cms.manage_podcast.add_manage_podcast');
|
||||
}
|
||||
|
||||
public function addData(Request $request){
|
||||
|
||||
// dd($request->all());
|
||||
$rules = [
|
||||
'image' => 'required|file|max:1000'// 1000 kb
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('image');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/manage_podcast';
|
||||
$file->move($path, $file_name);
|
||||
}
|
||||
|
||||
$podcastFile = $request->file('url');
|
||||
$podcastFileName = time() . '.' . $podcastFile->getClientOriginalExtension();
|
||||
$path = public_path() . '/uploads/manage_podcast/podcasts';
|
||||
$podcastFile->move($path, $podcastFileName);
|
||||
|
||||
$addPodcast = new ManagePodcast;
|
||||
$addPodcast->title = $request->title;
|
||||
$addPodcast->description = $request->description;
|
||||
$addPodcast->podcast_url = url('/public/uploads/manage_podcast/podcasts/' . $podcastFileName);
|
||||
// $addPodcast->podcast_url = $mp3File;
|
||||
$addPodcast->banner_image = url('/public/uploads/manage_podcast/' . $file_name);
|
||||
$addPodcast->save();
|
||||
|
||||
if($addPodcast){
|
||||
return response()->json([
|
||||
'message' => "Podcast Added Succesfully",
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
]);
|
||||
}else{
|
||||
return response()->json([
|
||||
'message' => "Something Went Wrong",
|
||||
'success' => true,
|
||||
'status' => 500,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function updateData(Request $request){
|
||||
|
||||
$updatepodcast = ManagePodcast::find($request->id);
|
||||
// dd($request->image);
|
||||
if($request->file('image')){
|
||||
$rules = [
|
||||
'image' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}else {
|
||||
$file = $request->file('image');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/manage_podcast';
|
||||
$file->move($path, $file_name);
|
||||
$updatepodcast->banner_image = url('/public/uploads/manage_podcast/' . $file_name);
|
||||
}
|
||||
}
|
||||
if($request->file('url')){
|
||||
|
||||
$podcastFile = $request->file('url');
|
||||
$podcastFileName = time() . '.' . $podcastFile->getClientOriginalExtension();
|
||||
$path = public_path() . '/uploads/manage_podcast/podcasts';
|
||||
$podcastFile->move($path, $podcastFileName);
|
||||
$updatepodcast->podcast_url = url('/public/uploads/manage_podcast/podcasts/' . $podcastFileName);
|
||||
}
|
||||
$updatepodcast->title = $request->title;
|
||||
$updatepodcast->description = $request->description;
|
||||
// $updatepodcast->podcast_url = $request->url;
|
||||
$updatepodcast->save();
|
||||
if($updatepodcast){
|
||||
return response()->json([
|
||||
'message' => "Podcast Updated Succesfully",
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
]);
|
||||
}else{
|
||||
return response()->json([
|
||||
'message' => "Something Went Wrong",
|
||||
'success' => true,
|
||||
'status' => 500,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteData(Request $request){
|
||||
|
||||
$deletePodcast = ManagePodcast::find($request->id)->delete();
|
||||
if($deletePodcast){
|
||||
return response()->json([
|
||||
'message' => "Podcast Deleted Succesfully",
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePodcastStatus(Request $request){
|
||||
|
||||
// dd($request->all());
|
||||
$status = ManagePodcast::where('id',$request->queId)->update(['is_active'=> $request->status]);
|
||||
return response()->json([
|
||||
'messages' => "Status Updated Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
25
app/Http/Controllers/Admin/ManagePreRecordedController.php
Normal file
25
app/Http/Controllers/Admin/ManagePreRecordedController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManagePreRecordedController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_pre_recorded.manage_pre_recorded_video');
|
||||
}
|
||||
|
||||
public function create_pre_recorded_video(){
|
||||
return view('Admin.Pages.manage_pre_recorded.add_manage_pre_recorded_video');
|
||||
}
|
||||
|
||||
public function edit_pre_recorded_video(){
|
||||
return view('Admin.Pages.manage_pre_recorded.edit_manage_pre_recorded_video');
|
||||
}
|
||||
|
||||
public function view_pre_recorded_video(){
|
||||
return view('Admin.Pages.manage_pre_recorded.view_manage_pre_recorded_video');
|
||||
}
|
||||
}
|
||||
108
app/Http/Controllers/Admin/ManageQuizController.php
Normal file
108
app/Http/Controllers/Admin/ManageQuizController.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ManageQuizQuestion;
|
||||
use App\Models\QuizQuestionsAnswer;
|
||||
|
||||
|
||||
class ManageQuizController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
|
||||
$data['quiz'] = ManageQuizQuestion::with('answer')->get()->toArray();
|
||||
// dd($data['quiz']);
|
||||
return view('Admin.Pages.manage_cms.manage_quiz.manage_quiz',$data);
|
||||
}
|
||||
public function add_quiz(){
|
||||
return view('Admin.Pages.manage_cms.manage_quiz.add_quiz');
|
||||
}
|
||||
public function edit_quiz($id){
|
||||
|
||||
// dd($id);
|
||||
$data['question'] = ManageQuizQuestion::where('id',$id)->get()->toArray();
|
||||
$data['answer'] = QuizQuestionsAnswer::where('question_id',$id)->get()->toArray();
|
||||
// dd($data);
|
||||
return view('Admin.Pages.manage_cms.manage_quiz.edit_quiz',$data);
|
||||
}
|
||||
|
||||
public function add_quiz_data(Request $request){
|
||||
|
||||
// dd($request->answer);
|
||||
|
||||
// Create and store the question
|
||||
if($request->schedule_time == null){
|
||||
$question = ManageQuizQuestion::create(['questions'=> $request->question,'is_active'=>'1']);
|
||||
}else{
|
||||
$question = ManageQuizQuestion::create(['questions'=> $request->question,'schedule_timing'=>$request->schedule_time,'is_active'=>'0']);
|
||||
}
|
||||
|
||||
if($question){
|
||||
// Create and store the answers
|
||||
$answersArr = [
|
||||
'A' => $request->ans_a,
|
||||
'B' => $request->ans_b,
|
||||
'C' => $request->ans_c,
|
||||
'D' => $request->ans_d,
|
||||
];
|
||||
foreach ($answersArr as $option => $content) {
|
||||
$isCorrect = ($request->answer == $option) ? '1' : '0';
|
||||
|
||||
QuizQuestionsAnswer::create([
|
||||
'question_id' => $question->id,
|
||||
'answers'=> $content,
|
||||
'is_active' => $isCorrect
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'messages' => "Question And Answer Is Added successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateQueStatus(Request $request){
|
||||
|
||||
$status = ManageQuizQuestion::where('id',$request->queId)->update(['is_active'=> $request->status]);
|
||||
return response()->json([
|
||||
'messages' => "Status Updated Successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
|
||||
public function updateQueAnsFormData(Request $request){
|
||||
|
||||
// dd($request->answer);
|
||||
|
||||
$question = ManageQuizQuestion::where('id',$request->queId)->update(['questions'=>$request->question]);
|
||||
|
||||
$rightAnsId = $request->answer;
|
||||
foreach($request->input('answers') as $option => $content){
|
||||
$isCorrect = ($option == $rightAnsId) ? '1' : '0';
|
||||
|
||||
$request = QuizQuestionsAnswer::where('id',$option)->update([
|
||||
'answers' => $content['content'],
|
||||
'is_active' => $isCorrect,
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'messages' => "Question And Answer Is Updated successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
|
||||
public function deleteQueAnsData($id){
|
||||
|
||||
$deleteQue = ManageQuizQuestion::find($id)->delete();
|
||||
$deleteAnswer = QuizQuestionsAnswer::where('question_id',$id)->delete();
|
||||
return response()->json([
|
||||
'messages' => "Question And Answer Is Deleted successfully",
|
||||
'success' => true,
|
||||
'status' => 200]);
|
||||
}
|
||||
}
|
||||
26
app/Http/Controllers/Admin/ManageReportsController.php
Normal file
26
app/Http/Controllers/Admin/ManageReportsController.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageReportsController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
|
||||
return view('Admin.Pages.manage_reports.manage_reports');
|
||||
}
|
||||
public function user_report_create(){
|
||||
|
||||
return view('Admin.Pages.manage_reports.user_report');
|
||||
}
|
||||
public function activities_report_create(){
|
||||
|
||||
return view('Admin.Pages.manage_reports.activities_report');
|
||||
}
|
||||
public function transaction_report_create(){
|
||||
|
||||
return view('Admin.Pages.manage_reports.transaction_report');
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Admin/ManageSettingController.php
Normal file
13
app/Http/Controllers/Admin/ManageSettingController.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageSettingController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_settings.manage_setting');
|
||||
}
|
||||
}
|
||||
90
app/Http/Controllers/Admin/ManageShortClipsController.php
Normal file
90
app/Http/Controllers/Admin/ManageShortClipsController.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\Admin\ManageShortClipsService;
|
||||
use App\Models\ManageShortClips;
|
||||
use App\Models\ShortClipsLikes;
|
||||
|
||||
class ManageShortClipsController extends Controller
|
||||
{
|
||||
public function __construct(ManageShortClipsService $manageShortClipsService)
|
||||
{
|
||||
$this->manageShortClipsService = $manageShortClipsService;
|
||||
}
|
||||
|
||||
public function create_short_clips()
|
||||
{
|
||||
return view('Admin.Pages.manage_short_clips.add_short_clips');
|
||||
}
|
||||
|
||||
public function insert(Request $request)
|
||||
{
|
||||
try {
|
||||
$shortClips = $this->manageShortClipsService->insert_short_clips($request);
|
||||
if(!empty($shortClips))
|
||||
{
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$data = $this->manageShortClipsService->get_all_short_clips();
|
||||
return view('Admin.Pages.manage_short_clips.manage_short_clips')->with(['data'=>$data]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
ManageShortClips::find($id)->delete();
|
||||
}
|
||||
|
||||
public function edit_short_clips($id)
|
||||
{
|
||||
$data = $this->manageShortClipsService->edit_short_clips($id)->toArray();
|
||||
return view('Admin.Pages.manage_short_clips.edit_short_clips')->with(['data'=>$data]);
|
||||
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->manageShortClipsService->update_short_clips($request);
|
||||
if(!empty($data))
|
||||
{
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function changestatus(Request $request)
|
||||
{
|
||||
// print_r($request->status);
|
||||
// exit;
|
||||
$status = ManageShortClips::find($request->user_id);
|
||||
$status->is_active = $request->status;
|
||||
$status->save();
|
||||
|
||||
|
||||
$changesSatus = ShortClipsLikes::where('short_clips_id', $request->user_id)->update(['is_active' => $request->status]);
|
||||
|
||||
return response()->json(['success'=>'Status change successfully.']);
|
||||
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Admin/ManageSubAdminController.php
Normal file
13
app/Http/Controllers/Admin/ManageSubAdminController.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageSubAdminController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_sub_admins.manage_sub_admin');
|
||||
}
|
||||
}
|
||||
17
app/Http/Controllers/Admin/ManageSubcriptionController.php
Normal file
17
app/Http/Controllers/Admin/ManageSubcriptionController.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageSubcriptionController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_subscription.manage_subscription');
|
||||
}
|
||||
public function create_archive_list(){
|
||||
return view('Admin.Pages.manage_subscription.manage_archive_list');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageSubcriptionPlansController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_subscription.manage_subscription_plans');
|
||||
}
|
||||
}
|
||||
51
app/Http/Controllers/Admin/ManageThoughtsController.php
Normal file
51
app/Http/Controllers/Admin/ManageThoughtsController.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManageThoughtsService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\UserThought;
|
||||
|
||||
class ManageThoughtsController extends Controller
|
||||
{
|
||||
public function __construct(ManageThoughtsService $manageThoughtsService)
|
||||
{
|
||||
$this->manageThoughtsService = $manageThoughtsService;
|
||||
}
|
||||
|
||||
public function view_manage_thoughts(Request $request)
|
||||
{
|
||||
$manage_thoughts =$this->manageThoughtsService->view_manage_thoughts($request);
|
||||
// dd($manage_thoughts);
|
||||
return view('Admin.Pages.manage_cms.manage_thoughts.manage_thoughts')->with(['manage_thought'=>$manage_thoughts]);
|
||||
}
|
||||
|
||||
public function insert_thoughts(Request $request)
|
||||
{
|
||||
// dd($request);
|
||||
$thoughts = $this->manageThoughtsService->insert_thoughts($request);
|
||||
return response()->json(['success' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
|
||||
public function update_thought(Request $request)
|
||||
{
|
||||
$updateThought = $this->manageThoughtsService->update_thought($request);
|
||||
return response()->json(['success2' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
public function change_manage_thoughts_Status(Request $request)
|
||||
{
|
||||
$status = UserThought::find($request->thought_id);
|
||||
$status->is_active = $request->status;
|
||||
$status->save();
|
||||
return response()->json(['success'=>'Status change successfully.']);
|
||||
}
|
||||
|
||||
public function delete_thought($id)
|
||||
{
|
||||
$Thoughts = UserThought::find($id)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
16
app/Http/Controllers/Admin/ManageTransactionController.php
Normal file
16
app/Http/Controllers/Admin/ManageTransactionController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageTransactionController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_transactions.manage_transactions');
|
||||
}
|
||||
public function create_manage_transactions_archive_list(){
|
||||
return view('Admin.Pages.manage_transactions.manage_transactions_archive_list');
|
||||
}
|
||||
}
|
||||
77
app/Http/Controllers/Admin/ManageVideoController.php
Normal file
77
app/Http/Controllers/Admin/ManageVideoController.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Admin\ManageVideoService;
|
||||
use Illuminate\Http\Request;
|
||||
use File;
|
||||
use App\Models\ManageFreeVideo;
|
||||
|
||||
|
||||
class ManageVideoController extends Controller
|
||||
{
|
||||
public function __construct(ManageVideoService $manageVideoService)
|
||||
{
|
||||
$this->manageVideoService = $manageVideoService;
|
||||
}
|
||||
|
||||
public function create(){
|
||||
return view('Admin.Pages.manage_cms.manage_video.manage_video');
|
||||
}
|
||||
|
||||
public function add_manage_video(){
|
||||
return view('Admin.Pages.manage_cms.manage_video.add_manage_video');
|
||||
}
|
||||
|
||||
public function view_manage_video(Request $request)
|
||||
{
|
||||
$manage_free_video =$this->manageVideoService->view_manage_video($request);
|
||||
// dd($manage_free_video);
|
||||
return view('Admin.Pages.manage_cms.manage_video.manage_video')->with(['manage_video'=>$manage_free_video]);
|
||||
}
|
||||
|
||||
public function insert_manage_video(Request $request)
|
||||
{
|
||||
$manage_free_video = $this->manageVideoService->insert_manage_video($request);
|
||||
return response()->json(['success' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
public function edit_manage_video($id){
|
||||
$manage_free_video = $this->manageVideoService->edit_manage_video($id);
|
||||
// echo "<pre>";
|
||||
// print_r($manage_free_video);
|
||||
// echo "</pre>";exit;
|
||||
|
||||
return view('Admin.Pages.manage_cms.manage_video.edit_manage_video')->with(['manage_free_video_getById'=>$manage_free_video]);
|
||||
}
|
||||
|
||||
public function delete_manage_video($id)
|
||||
{
|
||||
$manage_free_video = ManageFreeVideo::find($id);
|
||||
$manage_free_video->delete();
|
||||
$path = public_path().'/uploads/';
|
||||
File::delete($path.$manage_free_video->video_cover_image);
|
||||
return response()->json([
|
||||
'status'=> 200,
|
||||
'message'=> 'student Deleted Successfully',
|
||||
]);
|
||||
}
|
||||
|
||||
public function update_mange_video(Request $request)
|
||||
{
|
||||
$manage_free_video = $this->manageVideoService->update_mange_video($request);
|
||||
return response()->json(['success' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
public function change_manage_video_Status(Request $request)
|
||||
{
|
||||
// dd($request->faq_catag_id);
|
||||
$status = ManageFreeVideo::find($request->manage_thought_id);
|
||||
$status->is_active = $request->status;
|
||||
$status->save();
|
||||
return response()->json(['success'=>'Status change successfully.']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
321
app/Http/Controllers/Admin/SummerSweatController.php
Normal file
321
app/Http/Controllers/Admin/SummerSweatController.php
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ActivitySchedule;
|
||||
use App\Models\ActivityMaster;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\ActivityDay;
|
||||
|
||||
class SummerSweatController extends Controller {
|
||||
|
||||
public function create() {
|
||||
return view('Admin.Pages.manage_activities.summer_sweats.summer_sweat');
|
||||
}
|
||||
|
||||
// public function index() {
|
||||
// $manage_activity_schedule = ActivitySchedule::all()->toArray();
|
||||
//// echo "<pre>"; print_r($manage_activity_schedule);exit;
|
||||
// return view('Admin.Pages.manage_activities.summer_sweats.summer_sweat')->with(['manage_activity_schedule' => $manage_activity_schedule]);
|
||||
// }
|
||||
|
||||
public function add_create(Request $request) {
|
||||
|
||||
$get_single_activity = ActivityMaster::find($request->id)->toArray();
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
// echo "<pre>"; print_r($get_single_activity);exit;
|
||||
return view('Admin.Pages.manage_activities.summer_sweats.add_summer_sweat')->with(['get_data' => $get_single_activity, 'subcriptions' => $subcription]);
|
||||
}
|
||||
public function add_upcoming_create(Request $request) {
|
||||
|
||||
$get_single_activity = ActivityMaster::find($request->id)->toArray();
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
// echo "<pre>"; print_r($get_single_activity);exit;
|
||||
return view('Admin.Pages.manage_activities.summer_sweats.add_upcoming_summer_sweat')->with(['get_data' => $get_single_activity, 'subcriptions' => $subcription]);
|
||||
}
|
||||
|
||||
public function insert_summer_sweat(Request $request) {
|
||||
// echo "<pre>";print_r($request->all());die;
|
||||
// for image upload start
|
||||
// dd($request->all());
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_schedule';
|
||||
$file->move($path, $file_name);
|
||||
}
|
||||
|
||||
// for image upload end
|
||||
$activity_schedule = new ActivitySchedule;
|
||||
$activity_schedule->activity_master_id = $request->input('url_id');
|
||||
$activity_schedule->activity_teaser = $file_name;
|
||||
$activity_schedule->activity_name = $request->input('main_activity_name');
|
||||
$activity_schedule->description = $request->input('description');
|
||||
$activity_schedule->start_date = $request->input('start_date');
|
||||
$activity_schedule->end_date = $request->input('end_date');
|
||||
$activity_schedule->subscription_id = $request->input('subscription_id');
|
||||
|
||||
$start_date = strtotime($request->input('start_date'));
|
||||
$end_date = strtotime($request->input('end_date'));
|
||||
|
||||
// Retrieve the ActivityMaster record
|
||||
$activity_master = ActivityMaster::find($request->input('url_id'));
|
||||
|
||||
$activity_master_start = strtotime($activity_master->start_date);
|
||||
$activity_master_end = strtotime($activity_master->end_date);
|
||||
|
||||
// Check if start date and end date are within the activity master range
|
||||
if ($start_date >= $activity_master_start && $end_date <= $activity_master_end) {
|
||||
$activity_schedule->start_date = date('Y-m-d', $start_date);
|
||||
$activity_schedule->end_date = date('Y-m-d', $end_date);
|
||||
|
||||
$activity_schedule->save();
|
||||
return response()->json([
|
||||
'schedule_data' => $request->input('url_id'),
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Start date or end date is not within the activity master range.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function insert_upcoming_summer_sweat(Request $request) {
|
||||
// echo "<pre>";print_r($request->all());die;
|
||||
// for image upload start
|
||||
$rules = [
|
||||
'myFile' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('myFile');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_schedule';
|
||||
$file->move($path, $file_name);
|
||||
}
|
||||
|
||||
// for image upload end
|
||||
|
||||
$activity_schedule = new ActivitySchedule;
|
||||
$activity_schedule->activity_master_id = $request->input('url_id');
|
||||
$activity_schedule->activity_teaser = $file_name;
|
||||
$activity_schedule->activity_name = $request->input('main_activity_name');
|
||||
$activity_schedule->description = $request->input('description');
|
||||
$activity_schedule->start_date = $request->input('start_date');
|
||||
$activity_schedule->end_date = $request->input('end_date');
|
||||
$activity_schedule->subscription_id = $request->input('subscription_id');
|
||||
|
||||
$start_date = strtotime($request->input('start_date'));
|
||||
$end_date = strtotime($request->input('end_date'));
|
||||
|
||||
// Retrieve the ActivityMaster record
|
||||
$activity_master = ActivityMaster::find($request->input('url_id'));
|
||||
|
||||
$activity_master_start = strtotime($activity_master->start_date);
|
||||
$activity_master_end = strtotime($activity_master->end_date);
|
||||
|
||||
// Check if start date and end date are within the activity master range
|
||||
if ($start_date >= $activity_master_start && $end_date <= $activity_master_end) {
|
||||
$activity_schedule->start_date = date('Y-m-d', $start_date);
|
||||
$activity_schedule->end_date = date('Y-m-d', $end_date);
|
||||
|
||||
$activity_schedule->save();
|
||||
return response()->json([
|
||||
'schedule_data' => $request->input('url_id'),
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Start date or end date is not within the activity master range.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function edit_summer_sweat($id) {
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
$get_manage_activity_schedule = ActivitySchedule::find($id)->toArray();
|
||||
// dd($get_manage_activity_schedule);
|
||||
return view('Admin.Pages.manage_activities.summer_sweats.edit_summer_sweat')->with(['get_manage_activity' => $get_manage_activity_schedule, 'subcriptions' => $subcription,]);
|
||||
}
|
||||
public function edit_upcoming_summer_sweat($id) {
|
||||
$subcription = SubscriptionMaster::all()->toArray();
|
||||
$get_manage_activity_schedule = ActivitySchedule::find($id)->toArray();
|
||||
// dd($get_manage_activity_schedule);
|
||||
return view('Admin.Pages.manage_activities.summer_sweats.edit_upcoming_summer_sweat')->with(['get_manage_activity' => $get_manage_activity_schedule, 'subcriptions' => $subcription,]);
|
||||
}
|
||||
|
||||
public function update_summer_sweat(Request $request) {
|
||||
// for image upload start
|
||||
|
||||
if ($request->activity_teaser) {
|
||||
$rules = [
|
||||
'activity_teaser' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('activity_teaser');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_schedule';
|
||||
$file->move($path, $file_name);
|
||||
$file_name_store = url('/public/uploads/activity_banner_images/activity_schedule/' . $file_name);
|
||||
}
|
||||
// print_r($file_name_store);exit;
|
||||
} else {
|
||||
$file_name_store = $request->db_image;
|
||||
}
|
||||
// $file = $request->file('myFile');
|
||||
// $ext = $file->extension();
|
||||
// $file_name = time() . '.' . $ext;
|
||||
// $path = public_path() . '/uploads/activity_banner_images/activity_schedule';
|
||||
// $file->move($path, $file_name);
|
||||
// for image upload end
|
||||
|
||||
$activity_master_id = $request->edit_schedule_id;
|
||||
$activity_schedule = ActivitySchedule::find($request->edit_schedule_id);
|
||||
$activity_schedule->activity_teaser = $file_name_store;
|
||||
$activity_schedule->activity_name = $request->input('activity_name');
|
||||
$activity_schedule->description = $request->input('description');
|
||||
$activity_schedule->start_date = $request->input('start_date');
|
||||
$activity_schedule->end_date = $request->input('end_date');
|
||||
$activity_schedule->subscription_id = $request->input('subscription_id');
|
||||
|
||||
//End Date of schedule is not greater than activity end date logic
|
||||
$start_date = strtotime($request->input('start_date'));
|
||||
$end_date = strtotime($request->input('end_date'));
|
||||
|
||||
// Retrieve the ActivityMaster record
|
||||
$activity_master = ActivityMaster::find($request->input('activity_master_id'));
|
||||
|
||||
$activity_master_start = strtotime($activity_master->start_date);
|
||||
$activity_master_end = strtotime($activity_master->end_date);
|
||||
|
||||
if ($start_date >= $activity_master_start && $end_date <= $activity_master_end) {
|
||||
$activity_schedule->save();
|
||||
|
||||
return response()->json(['schedule_data' => $request->input('activity_master_id'),'success' => true, 'status' => 200]);
|
||||
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Start date or end date is not within the activity master range.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function update_upcoming_summer_sweat(Request $request) {
|
||||
// for image upload start
|
||||
// echo "<pre>"; print_r($request->all());exit;
|
||||
if ($request->activity_teaser) {
|
||||
$rules = [
|
||||
'activity_teaser' => 'required|file|max:400', // 400 KB
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(),$rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = $request->file('activity_teaser');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/activity_banner_images/activity_schedule';
|
||||
$file->move($path, $file_name);
|
||||
$file_name_store = url('/public/uploads/activity_banner_images/activity_schedule/' . $file_name);
|
||||
}
|
||||
// print_r($file_name_store);exit;
|
||||
} else {
|
||||
$file_name_store = $request->db_image;
|
||||
}
|
||||
// $file = $request->file('myFile');
|
||||
// $ext = $file->extension();
|
||||
// $file_name = time() . '.' . $ext;
|
||||
// $path = public_path() . '/uploads/activity_banner_images/activity_schedule';
|
||||
// $file->move($path, $file_name);
|
||||
// for image upload end
|
||||
|
||||
$activity_master_id = $request->edit_schedule_id;
|
||||
$activity_schedule = ActivitySchedule::find($request->edit_schedule_id);
|
||||
$activity_schedule->activity_teaser = $file_name_store;
|
||||
$activity_schedule->activity_name = $request->input('activity_name');
|
||||
$activity_schedule->description = $request->input('description');
|
||||
$activity_schedule->start_date = $request->input('start_date');
|
||||
$activity_schedule->end_date = $request->input('end_date');
|
||||
$activity_schedule->subscription_id = $request->input('subscription_id');
|
||||
|
||||
//End Date of schedule is not greater than activity end date logic
|
||||
$start_date = strtotime($request->input('start_date'));
|
||||
$end_date = strtotime($request->input('end_date'));
|
||||
|
||||
// Retrieve the ActivityMaster record
|
||||
$activity_master = ActivityMaster::find($request->input('activity_master_id'));
|
||||
|
||||
$activity_master_start = strtotime($activity_master->start_date);
|
||||
$activity_master_end = strtotime($activity_master->end_date);
|
||||
|
||||
if ($start_date >= $activity_master_start && $end_date <= $activity_master_end) {
|
||||
$activity_schedule->save();
|
||||
|
||||
return response()->json(['schedule_data' => $request->input('activity_master_id'),'success' => true, 'status' => 200]);
|
||||
|
||||
} else {
|
||||
return response()->json([
|
||||
'error_msg' => 'Start date or end date is not within the activity master range.',
|
||||
'success' => false,
|
||||
'status' => 400,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function delete_schedule($id) {
|
||||
|
||||
// dd($id);
|
||||
$manage_schedule = ActivitySchedule::find($id)->delete();
|
||||
// dd($manage_schedule);
|
||||
// if($manage_schedule == true){
|
||||
ActivityDay::where('activity_schedule_id',$id)->delete();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
78
app/Http/Controllers/Admin/TeacherController.php
Normal file
78
app/Http/Controllers/Admin/TeacherController.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Teacher;
|
||||
use File;
|
||||
|
||||
class TeacherController extends Controller {
|
||||
|
||||
public function index() {
|
||||
$manage_teacher = Teacher::all()->toArray();
|
||||
// echo "<pre>"; dd($manage_teacher);exit;
|
||||
return view('Admin.Pages.manage_teachers.manage_teacher')->with(['data' => $manage_teacher]);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
return view('Admin.Pages.manage_teachers.add_manage_teacher');
|
||||
}
|
||||
|
||||
public function insert(Request $request) {
|
||||
// for image upload start
|
||||
|
||||
$file = $request->file('teacher_image');
|
||||
$ext = $file->extension();
|
||||
$file_name = time() . '.' . $ext;
|
||||
$path = public_path() . '/uploads/teacher_images';
|
||||
$file->move($path, $file_name);
|
||||
|
||||
// for image upload end
|
||||
|
||||
$add_teacher = new Teacher;
|
||||
$add_teacher->teacher_title = $request->input('teacher_title');
|
||||
$add_teacher->teacher_sub_title = $request->input('teacher_sub_title');
|
||||
$add_teacher->description = $request->input('teacher_description');
|
||||
$add_teacher->address = $request->input('teacher_address');
|
||||
$add_teacher->teacher_image = $file_name;
|
||||
$add_teacher->contact_number = $request->input('teacher_contact_number');
|
||||
$add_teacher->save();
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
|
||||
public function delete_teacher($id) {
|
||||
$manage_teacher = Teacher::find($id)->delete();
|
||||
}
|
||||
|
||||
public function edit_teacher($id) {
|
||||
$manage_teacher = Teacher::find($id)->toArray();
|
||||
return view('Admin.Pages.manage_teachers.edit_manage_teacher')->with(['manage_teacher' => $manage_teacher]);
|
||||
}
|
||||
|
||||
public function update_teacher(Request $request) {
|
||||
|
||||
$teacher_data = Teacher::find($request->teacher_id);
|
||||
if ($request->hasFile('teacher_image')) {
|
||||
$path = public_path() . '/uploads/teacher_images';
|
||||
File::delete($path . $teacher_data->teacher_image);
|
||||
$file = $request->file('teacher_image');
|
||||
$ext = $file->extension();
|
||||
$file_name_main_image = time() . '.' . $ext;
|
||||
$file->move($path, $file_name_main_image);
|
||||
} else {
|
||||
$file_name_main_image = $teacher_data->teacher_image;
|
||||
}
|
||||
|
||||
|
||||
$teacher_data->teacher_title = $request->input('teacher_title');
|
||||
$teacher_data->teacher_sub_title = $request->input('teacher_sub_title');
|
||||
$teacher_data->description = $request->input('teacher_description');
|
||||
$teacher_data->teacher_image = url('/public/uploads/teacher_images/' . $file_name_main_image);
|
||||
$teacher_data->address = $request->input('teacher_address');
|
||||
$teacher_data->contact_number = $request->input('teacher_contact_number');
|
||||
$teacher_data->save();
|
||||
return response()->json(['success' => true, 'status' => 200]);
|
||||
}
|
||||
|
||||
}
|
||||
81
app/Http/Controllers/Admin/TestimonialController.php
Normal file
81
app/Http/Controllers/Admin/TestimonialController.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\Admin\ManageTestimonialService;
|
||||
use App\Models\Testimonial;
|
||||
use App\Models\TestimonialImages;
|
||||
use File;
|
||||
use Validator;
|
||||
|
||||
class TestimonialController extends Controller {
|
||||
|
||||
public function __construct(ManageTestimonialService $manageTestimonialService) {
|
||||
$this->manageTestimonialService = $manageTestimonialService;
|
||||
}
|
||||
|
||||
public function create_testimonial()
|
||||
{
|
||||
return view('Admin.Pages.manage_cms.testimonial.add_testimonial');
|
||||
}
|
||||
|
||||
public function insert_testimonial(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$testimonial = $this->manageTestimonialService->insert_testimonial($request);
|
||||
|
||||
if(!empty($testimonial))
|
||||
{
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function view_testimonial(Request $request) {
|
||||
$testimonials = $this->manageTestimonialService->view_testimonial($request)->toArray();
|
||||
// echo "<pre>"; print_r($testimonials);exit;
|
||||
return view('Admin.Pages.manage_cms.testimonial.testimonial')->with(['data' => $testimonials]);
|
||||
// return response()->json(['success' => true,'status'=>200]);
|
||||
}
|
||||
|
||||
public function delete_testimonial($id) {
|
||||
// print_r($id);die;
|
||||
$testimonials = Testimonial::find($id)->delete();
|
||||
}
|
||||
|
||||
public function edit_testimonial($id)
|
||||
{
|
||||
$data = $this->manageTestimonialService->edit_testimonial($id)->toArray();
|
||||
// dd($data);
|
||||
return view('Admin.Pages.manage_cms.testimonial.edit_testimonial')->with(['data'=>$data]);
|
||||
|
||||
}
|
||||
|
||||
public function update_testimonial(Request $request)
|
||||
{
|
||||
try {
|
||||
$data = $this->manageTestimonialService->update_testimonial($request);
|
||||
if(!empty($data)){
|
||||
return response()->json(['success' => true , 'status' => 200]);
|
||||
}
|
||||
else{
|
||||
return response()->json(['success' => false , 'status' => 422]);
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Message: ' .$e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
24
app/Http/Controllers/Admin/UserOverviewController.php
Normal file
24
app/Http/Controllers/Admin/UserOverviewController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\UserOverView;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\DataExport;
|
||||
|
||||
class UserOverviewController extends Controller
|
||||
{
|
||||
public function create(){
|
||||
return view('Admin.Pages.user_overview.user_overview');
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
// $date = $request->date;
|
||||
// $data = UserOverView::whereDate('created_at', $date)->get();
|
||||
return Excel::download(new DataExport, 'dataoverview.xlsx');
|
||||
}
|
||||
}
|
||||
40
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
40
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
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 = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
||||
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@@ -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;
|
||||
}
|
||||
40
app/Http/Controllers/Auth/LoginController.php
Normal file
40
app/Http/Controllers/Auth/LoginController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
}
|
||||
73
app/Http/Controllers/Auth/RegisterController.php
Normal file
73
app/Http/Controllers/Auth/RegisterController.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
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 = RouteServiceProvider::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']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
30
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
30
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
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 = RouteServiceProvider::HOME;
|
||||
}
|
||||
42
app/Http/Controllers/Auth/VerificationController.php
Normal file
42
app/Http/Controllers/Auth/VerificationController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
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 = RouteServiceProvider::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');
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
10
app/Http/Controllers/GSFExclusiveController.php
Normal file
10
app/Http/Controllers/GSFExclusiveController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GSFExclusiveController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
10
app/Http/Controllers/GetSetEatController.php
Normal file
10
app/Http/Controllers/GetSetEatController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GetSetEatController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
28
app/Http/Controllers/HomeController.php
Normal file
28
app/Http/Controllers/HomeController.php
Normal file
@@ -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,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TransformAndBeyondBeginnersController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
47
app/Http/Controllers/Website/ContactUsController.php
Normal file
47
app/Http/Controllers/Website/ContactUsController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ContactUs;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\ContactUsForm;
|
||||
|
||||
class ContactUsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
return view('website.pages.contact_us');
|
||||
}
|
||||
|
||||
public function send_contact_us(Request $req){
|
||||
|
||||
$contactdata = array(
|
||||
'name' => $req->full_name,
|
||||
'email_id' => $req->email,
|
||||
'subject' => $req->subject,
|
||||
'type' => $req->subject,
|
||||
'message' => $req->message,
|
||||
'is_reply' => '0',
|
||||
'is_active' => '1',
|
||||
);
|
||||
|
||||
$data = ContactUs::create($contactdata);
|
||||
$mail_details = [
|
||||
'email' => $req->email,
|
||||
'subject' => $req->subject,
|
||||
'body' => $req->message
|
||||
];
|
||||
$mail = Mail::to(['Support@Getsetfit.Co'])->send(new ContactUsForm($mail_details));
|
||||
// dd($mail);
|
||||
if ($mail) {
|
||||
|
||||
return response()->json(['success' => true, 'message' => 'Message Send Successfully', 'status' => 200]);
|
||||
}
|
||||
return response()->json(['success' => false, 'message' => 'Message failed to send', 'status' => 500]);
|
||||
|
||||
}
|
||||
}
|
||||
14
app/Http/Controllers/Website/DownloadController.php
Normal file
14
app/Http/Controllers/Website/DownloadController.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DownloadController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
return view('website.pages.download');
|
||||
}
|
||||
}
|
||||
14
app/Http/Controllers/Website/HomeController.php
Normal file
14
app/Http/Controllers/Website/HomeController.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
return view('website.pages.home_page');
|
||||
}
|
||||
}
|
||||
51
app/Http/Controllers/Website/Logincontroller.php
Normal file
51
app/Http/Controllers/Website/Logincontroller.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Logincontroller extends Controller
|
||||
{
|
||||
public function login(Request $request){
|
||||
|
||||
// print_r($request->all());
|
||||
// exit;
|
||||
$cread=$request->only('email','password');
|
||||
|
||||
$credentials = ['email_id' => $request->email,'password' => $request->password
|
||||
];
|
||||
|
||||
// Retrieve the user by their email or ID (you can use any identifier)
|
||||
$user = User::where('email_id', $request->input('email'))->first();
|
||||
// print_r(!$user);
|
||||
// exit;
|
||||
if(!$user) {
|
||||
return response()->json(['success' => false, 'message' => 'Invalid Email', 'status' => 404]);
|
||||
}else{
|
||||
if (Hash::check($credentials['password'], $user->password)) {
|
||||
|
||||
$login = Auth::login($user);
|
||||
$userData = Auth::user();
|
||||
$todaysDate = Carbon::now()->toDateString();
|
||||
$subscriptionEndDate = $userData->end_date;
|
||||
$subscriptionEndDate = Carbon::parse($subscriptionEndDate);
|
||||
|
||||
$subscriptionEndsIn7Days = $subscriptionEndDate->addDays(7)->toDateString();
|
||||
if($subscriptionEndsIn7Days == null || $subscriptionEndsIn7Days < $todaysDate)
|
||||
{
|
||||
return response()->json(['success' => true, 'message' => 'Your subscription has ended.', 'status' => 201]);
|
||||
}
|
||||
return response()->json(['success' => true, 'message' => 'Login Succefully', 'status' => 200]);
|
||||
} else {
|
||||
return response()->json(['success' => false, 'message' => 'Wrong Password', 'status' => 401]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
86
app/Http/Controllers/Website/OurServicesController.php
Normal file
86
app/Http/Controllers/Website/OurServicesController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
|
||||
class OurServicesController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
|
||||
return view('website.pages.our_services');
|
||||
}
|
||||
|
||||
//transform and beyond biginners
|
||||
public function transform_beyond_beginner(Request $request){
|
||||
|
||||
// $apiKey = "bdf20639fab33d6dc265da0f6926a491";
|
||||
// $ip = $request->ip(); // Get user's IP address
|
||||
|
||||
// $client = new Client();
|
||||
// $response = $client->get("http://api.ipstack.com/{$ip}?access_key={$apiKey}");
|
||||
$userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// Make a GET request to ipinfo.io
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// Parse the JSON response
|
||||
$data = $response->json();
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
// Get user's country code from the API response
|
||||
$userCountry['data'] = $data['country'];
|
||||
|
||||
// dd($userCountry);
|
||||
|
||||
return view('website.pages.transform_beyond_beginner',$userCountry);
|
||||
}
|
||||
|
||||
//gsf exclusive
|
||||
public function gsf_exclusive(Request $request){
|
||||
|
||||
// $apiKey = "bdf20639fab33d6dc265da0f6926a491";
|
||||
// $ip = $request->ip(); // Get user's IP address
|
||||
|
||||
// $client = new Client();
|
||||
// $response = $client->get("http://api.ipstack.com/{$ip}?access_key={$apiKey}");
|
||||
$userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// Make a GET request to ipinfo.io
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// Parse the JSON response
|
||||
$data = $response->json();
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
// Get user's country code from the API response
|
||||
$userCountry['data'] = $data['country'];
|
||||
|
||||
// dd($userCountry);
|
||||
|
||||
return view('website.pages.gsf_exclusive',$userCountry);
|
||||
}
|
||||
|
||||
// get set eat
|
||||
public function get_set_eat(Request $request){
|
||||
|
||||
// $apiKey = "bdf20639fab33d6dc265da0f6926a491";
|
||||
// $ip = $request->ip(); // Get user's IP address
|
||||
|
||||
// $client = new Client();
|
||||
// $response = $client->get("http://api.ipstack.com/{$ip}?access_key={$apiKey}");
|
||||
$userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// Make a GET request to ipinfo.io
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// Parse the JSON response
|
||||
$data = $response->json();
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
// Get user's country code from the API response
|
||||
$userCountry['data'] = $data['country'];
|
||||
|
||||
// dd($userCountry);
|
||||
|
||||
return view('website.pages.get_set_eat',$userCountry);
|
||||
}
|
||||
}
|
||||
35
app/Http/Controllers/Website/TransformBeyondController.php
Normal file
35
app/Http/Controllers/Website/TransformBeyondController.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class TransformBeyondController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
|
||||
// $apiKey = "bdf20639fab33d6dc265da0f6926a491";
|
||||
// $ip = $request->ip(); // Get user's IP address
|
||||
|
||||
// $client = new Client();
|
||||
// $response = $client->get("http://api.ipstack.com/{$ip}?access_key={$apiKey}");
|
||||
|
||||
$userIP = $request->ip(); // Get the user's IP address
|
||||
|
||||
// Make a GET request to ipinfo.io
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}?token=fb9b51b5a3bbd9");
|
||||
// Parse the JSON response
|
||||
$data = $response->json();
|
||||
// dd($data);
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
// Get user's country code from the API response
|
||||
$userCountry['data'] = $data['country'];
|
||||
|
||||
// dd($userCountry);
|
||||
|
||||
return view('website.pages.transform_beyond',$userCountry);
|
||||
}
|
||||
}
|
||||
155
app/Http/Controllers/Website/YourActivityController.php
Normal file
155
app/Http/Controllers/Website/YourActivityController.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Website;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ActivityMaster;
|
||||
use App\Models\SubscriptionMaster;
|
||||
use App\Models\ActivitySchedule;
|
||||
use App\Models\ActivityDay;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\ManageFaq;
|
||||
use App\Models\LinkFaqActivityMasterIds;
|
||||
use App\Models\PastSession;
|
||||
use Carbon\Carbon;
|
||||
use DateTimeZone;
|
||||
use DateTime;
|
||||
use Auth;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Torann\GeoIP\Facades\GeoIP;
|
||||
use Spatie\TimeZone\GoogleTimeZone;
|
||||
|
||||
class YourActivityController extends Controller
|
||||
{
|
||||
public function index(Request $request){
|
||||
$data=[];
|
||||
$current_day = now()->format('Y-m-d'); // Get the current date in the format "YYYY-MM-DD"
|
||||
$user_data = Auth::user();
|
||||
|
||||
$userIP = \Request::ip();
|
||||
$response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
$locationData = $response->json();
|
||||
$userTimeZone = $locationData['timezone'];
|
||||
|
||||
$user_data = Auth::user();
|
||||
$utm_source = $user_data->utm_source;
|
||||
$subscription_data = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
$subscription_id = $subscription_data->id;
|
||||
$data['live_activity'] = ActivityDay::where('subscription_id', $subscription_id)
|
||||
->where('date', 'LIKE', "%$current_day%")
|
||||
->with('scheduleData', 'activityData')
|
||||
->get();
|
||||
// dd($data['live_activity']);
|
||||
|
||||
// dd($data['live_activity']);
|
||||
// if($data['live_activity']->isEmpty()){
|
||||
// $data['data'] = ['0'];
|
||||
// dd($data);
|
||||
// return view('website.pages.your_activity',compact('data'));
|
||||
// }else{
|
||||
if(!$data['live_activity']->isEmpty()){
|
||||
$timestamp = $data['live_activity'][0]['time'];
|
||||
// dd($timestamp);
|
||||
$gettimezone = $userTimeZone;
|
||||
// $datetime = "2016-02-01 00:00:01";
|
||||
// Target timezone based on the user's IP address
|
||||
$targetTimeZone = new DateTimeZone($userTimeZone);
|
||||
|
||||
// Create a DateTime object for the original timestamp in India timezone
|
||||
$given = new DateTime($timestamp, new DateTimeZone('Asia/Kolkata'));
|
||||
|
||||
// Set the target timezone
|
||||
$given->setTimezone($targetTimeZone);
|
||||
// $given = new DateTime($timestamp, new DateTimeZone($gettimezone));
|
||||
// $given->setTimezone(new DateTimeZone("UTC"));
|
||||
$output = $given->format("H:i");
|
||||
$data['live_activity'][0]['time']=$output;
|
||||
}
|
||||
$data['subscription_data'] = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
// return $data;
|
||||
//past data
|
||||
$subscription_data = SubscriptionMaster::where('utm_plan',$utm_source)->first();
|
||||
$subscription_id = $subscription_data->id;
|
||||
|
||||
// dd($subscription_id);
|
||||
// Calculate the cutoff date (end date + 7 days)
|
||||
$activity_data = ActivityMaster::where('subscription_id', $subscription_id)->orderBy('end_date', 'desc')->first();
|
||||
// return $activity_data;
|
||||
// dd($activity_data);
|
||||
$end_date = $activity_data->end_date;
|
||||
// dd($end_date);
|
||||
$cutoffDate = Carbon::parse($end_date)->addDays(7)->toDateString();
|
||||
// dd($cutoffDate);
|
||||
// $desired_date = Carbon::createFromDate(2024, 1, 2);
|
||||
// $cutoffDate = $desired_date->format('Y-m-d');
|
||||
$current_date = Carbon::now()->format('Y-m-d');
|
||||
$data['data'] = [];
|
||||
// dd($cutoffDate);
|
||||
// Check if the current date is past the cutoff date
|
||||
if (Carbon::now()->toDateString() > $cutoffDate) {
|
||||
|
||||
$data['data'] = ['0'];
|
||||
// dd($data);
|
||||
return view('website.pages.your_activity',compact('data'));
|
||||
}
|
||||
|
||||
$data['past_activity'] = ActivityMaster::where('subscription_id', $subscription_id)->where('end_date','<',$cutoffDate)->with('teacher_data')->orderBy('start_date', 'desc')->first();
|
||||
// dd($data['past_activity']);
|
||||
if ($data['past_activity'] !== null) {
|
||||
$schedule_data = ActivitySchedule::where('activity_master_id', $data['past_activity']['id'])->with('past_data')->orderBy('start_date', 'asc')->get()->toArray();
|
||||
// dd($schedule_data);
|
||||
} else {
|
||||
$data['past_activity'] = [];
|
||||
$schedule_data = []; // Set an empty array when $data['past_activity'] is null
|
||||
}
|
||||
|
||||
|
||||
$data_schedule = [];
|
||||
foreach ($schedule_data as $k => $val){
|
||||
if (empty($val['past_data'])){
|
||||
continue;
|
||||
}else{
|
||||
$data_schedule[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$data['past_activity']['schedule'] = $data_schedule;
|
||||
|
||||
|
||||
// $userIP = $request->ip();
|
||||
|
||||
// $response = Http::get("https://ipinfo.io/{$userIP}/json");
|
||||
// $locationData = $response->json();
|
||||
// // dd($locationData);
|
||||
// $userTimeZone = $locationData['timezone'];
|
||||
// // dd($userTimeZone);
|
||||
|
||||
// $timestamp = $data['live_activity'][0]->new_time; // Use square brackets to access elements
|
||||
// // dd()
|
||||
// $originalTime = Carbon::parse($timestamp,$userTimeZone);
|
||||
// $date = Carbon::createFromFormat('H:i:s', $timestamp, 'UTC');
|
||||
// $date->setTimezone($userTimeZone);
|
||||
// dd($date);
|
||||
// $userTime = $originalTime->copy();
|
||||
// $userTime->setTimezone($userTimeZone);
|
||||
// $userTimeFormatted = $userTime->format('H:i:s');
|
||||
// // dd($userTimeFormatted);
|
||||
// $data['live_activity'] = $data['live_activity']->map(function ($item) use ($userTimeZone) {
|
||||
// $timestamp = $item->new_time;
|
||||
// // $normalTime = Carbon::createFromFormat('H:i', $timestamp, $userTimeZone); // Replace 'your_timezone' with the actual timezone of the 'time' column
|
||||
// $normalTime = Carbon::parse($timestamp, $userTimeZone);
|
||||
// $convertedTime = $normalTime->setTimezone($userTimeZone); // Convert to the user's time zone
|
||||
// $item->new_time = $convertedTime->format('H:i'); // Update the 'time' value with the user's time zone in 'HH:mm' format
|
||||
// return $item;
|
||||
// })->toArray();
|
||||
|
||||
// echo "<pre>";
|
||||
// print_r($data['live_activity']);
|
||||
// exit;
|
||||
|
||||
return view('website.pages.your_activity',$data);
|
||||
}
|
||||
}
|
||||
14
app/Http/Helpers/ApiResponseHelper.php
Normal file
14
app/Http/Helpers/ApiResponseHelper.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/EmptyPHP.php to edit this template
|
||||
*/
|
||||
|
||||
function api_response($code, $message, $data){
|
||||
return [
|
||||
"status_code" => $code,
|
||||
"message"=>$message,
|
||||
"data"=>$data
|
||||
];
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user