-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into mail-verification-test
- Loading branch information
Showing
212 changed files
with
2,232 additions
and
1,156 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
app/Console/Commands/Subscriptions/MigrateSubscriptions.php
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,85 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands\Subscriptions; | ||
|
||
use Illuminate\Console\Command; | ||
use Laravel\Cashier\Subscription; | ||
|
||
class MigrateSubscriptions extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'migrate:subscriptions'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Update subscribers to the new sub pricing'; | ||
|
||
protected int $count = 0; | ||
protected int $limit = 400; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
$old = config('subscription.old.all'); | ||
|
||
Subscription::with(['user', 'user.subscriptions', 'user.subscriptions.owner']) | ||
->where('stripe_status', 'active') | ||
->whereIn('stripe_price', $old) | ||
->has('user') | ||
->chunkById(200, function ($subs) { | ||
if ($this->count > $this->limit) { | ||
return false; | ||
} | ||
foreach ($subs as $s) { | ||
if ($this->count > $this->limit) { | ||
return false; | ||
} | ||
$this->info('User #' . $s->user->id . ' ' . $s->user->email . ' https://dashboard.stripe.com/customers/' . $s->user->stripe_id); | ||
try { | ||
$old = $s->stripe_price; | ||
$new = $this->map($old); | ||
if ($new === 'error' || empty($new)) { | ||
$this->error('Invalid old price ' . $old . ' to ' . $new); | ||
continue; | ||
} | ||
$s->user->subscription('kanka')->noProrate()->swap($new); | ||
$this->info('(' . $s->user->pledge . '): ' . $old . ' => ' . $new); | ||
} catch (\Exception $e) { | ||
$this->error($e->getMessage()); | ||
} | ||
$this->count++; | ||
} | ||
}); | ||
|
||
} | ||
|
||
protected function map(string $price): string | ||
{ | ||
return match($price) { | ||
config('subscription.old.oe') => config('subscription.owlbear.eur.monthly'), | ||
config('subscription.old.oey') => config('subscription.owlbear.eur.yearly'), | ||
config('subscription.old.ou') => config('subscription.owlbear.usd.monthly'), | ||
config('subscription.old.ouy') => config('subscription.owlbear.usd.yearly'), | ||
|
||
config('subscription.old.we') => config('subscription.wyvern.eur.monthly'), | ||
config('subscription.old.wey') => config('subscription.wyvern.eur.yearly'), | ||
config('subscription.old.wu') => config('subscription.wyvern.usd.monthly'), | ||
config('subscription.old.wuy') => config('subscription.wyvern.usd.yearly'), | ||
|
||
config('subscription.old.ee') => config('subscription.elemental.eur.monthly'), | ||
config('subscription.old.eey') => config('subscription.elemental.eur.yearly'), | ||
config('subscription.old.eu') => config('subscription.elemental.usd.monthly'), | ||
config('subscription.old.euy') => config('subscription.elemental.usd.yearly'), | ||
default => 'error', | ||
}; | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
app/Http/Controllers/Calendars/Bulks/EntityEventController.php
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,39 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Calendars\Bulks; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Controllers\Datagrid2\BulkControllerTrait; | ||
use App\Models\Campaign; | ||
use App\Models\Calendar; | ||
use App\Models\EntityEvent; | ||
use App\Traits\CampaignAware; | ||
use Illuminate\Http\Request; | ||
|
||
class EntityEventController extends Controller | ||
{ | ||
use BulkControllerTrait; | ||
use CampaignAware; | ||
|
||
public function index(Request $request, Campaign $campaign, Calendar $calendar) | ||
{ | ||
$this->authorize('update', $calendar); | ||
$action = $request->get('action'); | ||
$models = $request->get('model'); | ||
if (!in_array($action, $this->validBulkActions()) || empty($models)) { | ||
return redirect()->back(); | ||
} | ||
|
||
if ($action === 'edit') { | ||
return $this->campaign($campaign)->bulkBatch(route('calendars.entity-events.bulk', [ | ||
'campaign' => $campaign, 'calendar' => $calendar]), '_calendar-event', $models, $calendar); | ||
} | ||
|
||
$count = $this->campaign($campaign)->bulkProcess($request, EntityEvent::class); | ||
|
||
return redirect() | ||
->route('calendars.events', [$campaign, 'calendar' => $calendar]) | ||
->with('success', trans_choice('calendars.events.bulks.' . $action, $count, ['count' => $count])) | ||
; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,58 +36,53 @@ class CrudController extends Controller | |
use HasDatagrid; | ||
use HasSubview; | ||
|
||
/** @var string The view where to find the resources */ | ||
/** The view where to find the resources */ | ||
protected string $view = ''; | ||
|
||
/** @var string The name of the route for the resource */ | ||
/** The name of the route for the resource */ | ||
protected string $route = ''; | ||
|
||
/** @var MiscModel|Model|string|null */ | ||
protected $model = null; | ||
protected $model; | ||
|
||
protected string $filter; | ||
|
||
/** @var FilterService */ | ||
protected $filterService; | ||
/** */ | ||
protected FilterService $filterService; | ||
|
||
/** @var bool If the permissions tab and pane is enabled or not. */ | ||
/** If the permissions tab and pane is enabled or not. */ | ||
protected bool $tabPermissions = true; | ||
|
||
/** @var bool If the attributes tab and pane is enabled or not */ | ||
/** If the attributes tab and pane is enabled or not */ | ||
protected bool $tabAttributes = true; | ||
|
||
/** @var bool If the copy tab and pane is enabled or not */ | ||
/** If the copy tab and pane is enabled or not */ | ||
protected bool $tabCopy = true; | ||
|
||
/** @var bool If the boosted tab and pane is enabled or not */ | ||
/** If the boosted tab and pane is enabled or not */ | ||
protected bool $tabBoosted = true; | ||
|
||
/** @var array List of navigation actions on top of the datagrids */ | ||
/** List of navigation actions on top of the datagrids */ | ||
protected array $navActions = []; | ||
|
||
/** @var string Make the request play nice with the model */ | ||
/** Make the request play nice with the model */ | ||
protected string $sanitizer = MiscSanitizer::class; | ||
|
||
/** | ||
* A sorter object for subviews | ||
* @var null|DatagridSorter | ||
*/ | ||
protected $datagridSorter = null; | ||
protected DatagridSorter $datagridSorter; | ||
Check failure on line 75 in app/Http/Controllers/CrudController.php GitHub Actions / PHP 8.3
|
||
|
||
/** @var bool If the auth check was already performed on this controller */ | ||
/** If the auth check was already performed on this controller */ | ||
protected bool $alreadyAuthChecked = false; | ||
|
||
/** @var string The datagrid actions, set to null to disable */ | ||
/** The datagrid actions, set to null to disable */ | ||
protected string $datagridActions = DefaultDatagridActions::class; | ||
|
||
/** @var bool Determine if the create/store procedure has a limit checking in place */ | ||
/** Determine if the create/store procedure has a limit checking in place */ | ||
protected bool $hasLimitCheck = false; | ||
|
||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('campaign.member'); | ||
|
@@ -222,8 +217,8 @@ public function crudIndex(Request $request) | |
'entityTypeId', | ||
'singular', | ||
); | ||
if (!empty($this->titleKey)) { | ||
$data['titleKey'] = $this->titleKey; | ||
if (method_exists($this, 'titleKey')) { | ||
$data['titleKey'] = $this->titleKey(); | ||
} else { | ||
$data['titleKey'] = Module::plural($entityTypeId, __('entities.' . $langKey)); | ||
} | ||
|
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
Oops, something went wrong.