-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from TheRestartProject/RES-1942_negative_atte…
…ndees RES-1942 Negative attendee count
- Loading branch information
Showing
7 changed files
with
147 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use DB; | ||
use Illuminate\Console\Command; | ||
use App\Party; | ||
|
||
class FixVolunteerCount extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'dev:fixvolunteercount'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Fix the volunteer count for all events'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$events = Party::all(); | ||
|
||
foreach ($events as $event) { | ||
$actual = DB::table('events_users')->where('event', $event->idevents)->where('status', 1)->count(); | ||
|
||
if ($actual > $event->volunteers) { | ||
if ($event->volunteers < 0) { | ||
$this->info("Event {$event->idevents} has negative count {$event->volunteers}, $actual have confirmed"); | ||
} else { | ||
$this->info("Event {$event->idevents} has count {$event->volunteers}, but more ($actual) have confirmed"); | ||
} | ||
|
||
$event->volunteers = $actual; | ||
$event->save(); | ||
} else if ($event->volunteers < 0) { | ||
$this->info("Event {$event->idevents} has negative count {$event->volunteers}, fewewr ($actual) have confirmed"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters