api code global jain
This commit is contained in:
60
app/Console/Commands/AddProfileCompletionPercentage.php
Normal file
60
app/Console/Commands/AddProfileCompletionPercentage.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Exception;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AddProfileCompletionPercentage extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'add:profile-percentage';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Counts & adds profile completion percentage';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$users = User::with('userDetail', 'userWorkDetail', 'userQualification')->get();
|
||||
|
||||
if ($users) {
|
||||
foreach ($users as $user) {
|
||||
$userProfileCompletion = calculateActivity($user->toArray());
|
||||
$user['profile_statistics'] = $userProfileCompletion;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->info(trans(__('Command executed successfully!')));
|
||||
|
||||
} catch(Exception $ex) {
|
||||
Log::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
60
app/Console/Commands/AddSantProfileCompletionPercentage.php
Normal file
60
app/Console/Commands/AddSantProfileCompletionPercentage.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Exception;
|
||||
use App\Models\Sant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AddSantProfileCompletionPercentage extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'add:sant-profile-percentage';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Counts & adds sant profile completion percentage';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$sants = Sant::get();
|
||||
|
||||
if ($sants) {
|
||||
foreach ($sants as $sant) {
|
||||
$santProfileCompletion = calculateSantActivity($sant->toArray());
|
||||
$sant['profile_statistics'] = $santProfileCompletion;
|
||||
$sant->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->info(trans(__('Command executed successfully!')));
|
||||
|
||||
} catch(Exception $ex) {
|
||||
Log::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
126
app/Console/Commands/ReplaceVihaarEndLocation.php
Normal file
126
app/Console/Commands/ReplaceVihaarEndLocation.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Exception;
|
||||
use App\Models\Sant;
|
||||
use App\Constant\Constant;
|
||||
use App\Models\ThanaMember;
|
||||
use App\Models\SantLocation;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ReplaceVihaarEndLocation extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'check:vihaar';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'It checks if vihaar is ended and replace sant\'s location';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$sants = Sant::with([
|
||||
'location.createdBy:id,name,avatar',
|
||||
'location.updatedBy:id,name,avatar',
|
||||
])->get()->toArray();
|
||||
|
||||
foreach ($sants as $sant) {
|
||||
$thanaID = Constant::NULL;
|
||||
$thanaSantID = [];
|
||||
|
||||
$thanaID = ThanaMember::where('sant_id', $sant['id'])->value('thana_id');
|
||||
$thanaSantID = ThanaMember::where('thana_id', $thanaID)->pluck('sant_id');
|
||||
|
||||
if (!empty($sant['location'])) {
|
||||
// $santLocation = SantLocation::find($sant['location']['sant_id']);
|
||||
$santLocation = SantLocation::where('sant_id', $sant['location']['sant_id'])->first();
|
||||
|
||||
if (empty($santLocation)) {
|
||||
if (!empty($thanaSantID) && count($thanaSantID) > 0) {
|
||||
foreach ($thanaSantID as $santID) {
|
||||
SantLocation::create([
|
||||
'sant_id' => $santID,
|
||||
'sangh_id' => Constant::NULL,
|
||||
'type' => isset($sant['location']['to_sangh_id']) ? Constant::STATUS_TWO : Constant::STATUS_ONE,
|
||||
'location' => $sant['location']['to'],
|
||||
'latitude' => $sant['location']['to_latitude'],
|
||||
'longitude' => $sant['location']['to_longitude'],
|
||||
'created_by' => $sant['location']['created_by']['id'] ?? Constant::NULL,
|
||||
'updated_by' => Constant::NULL,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
SantLocation::create([
|
||||
'sant_id' => $sant['id'] ?? Constant::NULL,
|
||||
'sangh_id' => Constant::NULL,
|
||||
'type' => isset($sant['location']['to_sangh_id']) ? Constant::STATUS_TWO : Constant::STATUS_ONE,
|
||||
'location' => $sant['location']['to'],
|
||||
'latitude' => $sant['location']['to_latitude'],
|
||||
'longitude' => $sant['location']['to_longitude'],
|
||||
'created_by' => $sant['location']['created_by']['id'] ?? Constant::NULL,
|
||||
'updated_by' => Constant::NULL,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if (!empty($thanaSantID) && count($thanaSantID) > 0) {
|
||||
foreach ($thanaSantID as $santID) {
|
||||
if ($santID == $santLocation->sant_id) {
|
||||
$santLocation->update([
|
||||
'sant_id' => $santID,
|
||||
'sangh_id' => Constant::NULL,
|
||||
'type' => $santLocation->type,
|
||||
'location' => $sant['location']['to'] ?? $santLocation->location,
|
||||
'latitude' => $sant['location']['to_latitude'] ?? $santLocation->latitude,
|
||||
'longitude' => $sant['location']['to_longitude'] ?? $santLocation->longitude,
|
||||
'created_by' => $santLocation->created_by ?? Constant::NULL,
|
||||
'updated_by' => $sant['location']['created_by']['id'] ?? Constant::NULL,
|
||||
]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$santLocation->update([
|
||||
'sant_id' => $sant['id'] ?? $santLocation->sant_id,
|
||||
'sangh_id' => Constant::NULL,
|
||||
'type' => $santLocation->type,
|
||||
'location' => $sant['location']['to'] ?? $santLocation->location,
|
||||
'latitude' => $sant['location']['to_latitude'] ?? $santLocation->latitude,
|
||||
'longitude' => $sant['location']['to_longitude'] ?? $santLocation->longitude,
|
||||
'created_by' => $santLocation->created_by ?? Constant::NULL,
|
||||
'updated_by' => $sant['location']['created_by']['id'] ?? Constant::NULL,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->info(trans(__('Command executed successfully!')));
|
||||
|
||||
} catch(Exception $ex) {
|
||||
Log::error($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/Console/Commands/SendMemberIDNotification.php
Normal file
45
app/Console/Commands/SendMemberIDNotification.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\SendGenerateMemberID;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendMemberIDNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'generate:memberid';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate your member ID';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
dispatch(new SendGenerateMemberID());
|
||||
$this->info('Notification generate memberID dispatched successfully!');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
43
app/Console/Commands/SendNewAppNotification.php
Normal file
43
app/Console/Commands/SendNewAppNotification.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\Notifications\NewApp\SendDownloadNewApp;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendNewAppNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'download:new-app';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
dispatch(new SendDownloadNewApp());
|
||||
}
|
||||
}
|
||||
57
app/Console/Commands/memberIdGenerate.php
Normal file
57
app/Console/Commands/memberIdGenerate.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\SanghMember;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class memberIdGenerate extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'add:member-id';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Add member id to sangh member table';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$membersGroupedBySangh = SanghMember::orderBy('id')->get()->groupBy('sangh_id');
|
||||
|
||||
foreach ($membersGroupedBySangh as $sanghId => $members) {
|
||||
$counter = 1;
|
||||
|
||||
foreach ($members as $member) {
|
||||
$newMemberId = str_pad($counter, 4, '0', STR_PAD_LEFT);
|
||||
$member->update(['member_id' => $newMemberId]);
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Member IDs added to columns successfully.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user