Skip to content

Commit

Permalink
Merge branch 'develop' into mail-verification-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ilestis authored Feb 19, 2024
2 parents e9e0d4f + 7a23280 commit b6fccb6
Show file tree
Hide file tree
Showing 212 changed files with 2,232 additions and 1,156 deletions.
85 changes: 85 additions & 0 deletions app/Console/Commands/Subscriptions/MigrateSubscriptions.php
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',
};
}
}
13 changes: 5 additions & 8 deletions app/Console/Commands/Subscriptions/UpcomingYearlyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ public function __construct()
*/
public function handle()
{
$plans = [
config('subscription.owlbear.eur.yearly'),
config('subscription.owlbear.usd.yearly'),
config('subscription.wyvern.eur.yearly'),
config('subscription.wyvern.usd.yearly'),
config('subscription.elemental.eur.yearly'),
config('subscription.elemental.usd.yearly'),
];
$plans = array_merge(
config('subscription.owlbear.yearly'),
config('subscription.wyvern.yearly'),
config('subscription.elemental.yearly'),
);

$now = Carbon::now()->addMonth();
$log = "Looking for active yearly subscriptions created on month {$now->month} and day {$now->day}";
Expand Down
5 changes: 5 additions & 0 deletions app/Datagrids/Bulks/CreatureBulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ class CreatureBulk extends Bulk
'creature_id',
'tags',
'private_choice',
'extinct_choice',
'entity_image',
'entity_header',
];

protected $booleans = [
'is_extinct'
];
}
1 change: 1 addition & 0 deletions app/Datagrids/Filters/CreatureFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function build()
'model' => Creature::class,
])
->location()
->add('is_extinct')
->isPrivate()
->template()
->hasImage()
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Api/v1/CampaignApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class CampaignApiController extends ApiController
{
public function index(\Illuminate\Http\Request $request)
{
// @phpstan-ignore-next-line
$campaigns = $request
->user()
->campaigns()
Expand Down
39 changes: 39 additions & 0 deletions app/Http/Controllers/Calendars/Bulks/EntityEventController.php
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]))
;
}
}
5 changes: 3 additions & 2 deletions app/Http/Controllers/Calendars/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Traits\Controllers\HasSubview;
use App\Traits\GuestAuthTrait;
use Exception;
use Illuminate\Support\Str;

class EventController extends Controller
{
Expand Down Expand Up @@ -77,9 +78,9 @@ public function create(Campaign $campaign, Calendar $calendar)
{
$this->authorize('update', $calendar);

$date = request()->get('date');
$date = request()->get('date', '1-1-1');
list($year, $month, $day) = explode('-', $date);
if (str_starts_with($date, '-')) {
if (Str::startsWith($date, '-')) {
list($year, $month, $day) = explode('-', trim($date, '-'));
$year = "-{$year}";
}
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Campaign/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function index(Campaign $campaign)

Datagrid::layout(\App\Renderers\Layouts\Campaign\CampaignImport::class);

// @phpstan-ignore-next-line
$rows = $campaign->campaignImports()
->sort(request()->only(['o', 'k']))
->where('status_id', '<>', CampaignImportStatus::PREPARED)
Expand Down
20 changes: 0 additions & 20 deletions app/Http/Controllers/Campaign/RoleUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ class RoleUserController extends Controller

protected MemberService $service;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(MemberService $service)
{
$this->middleware('auth');
Expand All @@ -34,10 +29,6 @@ public function index(Campaign $campaign)
return redirect()->route('campaign_roles.index', $campaign);
}

/**
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function create(Campaign $campaign, CampaignRole $campaignRole)
{
$this->authorize('roles', $campaign);
Expand All @@ -46,10 +37,6 @@ public function create(Campaign $campaign, CampaignRole $campaignRole)
return view($this->view . '.create', ['campaign' => $campaign, 'role' => $campaignRole]);
}

/**
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function store(StoreCampaignRoleUser $request, Campaign $campaign, CampaignRole $campaignRole)
{
$this->authorize('roles', $campaign);
Expand All @@ -69,19 +56,12 @@ public function store(StoreCampaignRoleUser $request, Campaign $campaign, Campai
]));
}

/**
* @return \Illuminate\Http\RedirectResponse
*/
public function show(Campaign $campaign, CampaignRole $campaignRole, CampaignRoleUser $campaignRoleUser)
{
return redirect()
->route('campaign_roles.show', [$campaign, $campaignRole]);
}

/**
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function destroy(Campaign $campaign, CampaignRole $campaignRole, CampaignRoleUser $campaignRoleUser)
{
$this->authorize('roles', $campaign);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Campaign/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function index(Campaign $campaign)
$this->rows = $campaign
->members()
->sort(request()->only(['o', 'k']), ['id' => 'desc'])
->with(['user', 'campaign', 'user.campaignRoles', 'user.campaignRoleUser'])
->with(['user', 'campaign', 'user.campaignRoles', 'user.campaignRoleUser', 'user.tutorials'])
->paginate();

$invitations = $campaign
Expand Down
39 changes: 17 additions & 22 deletions app/Http/Controllers/CrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / PHP 8.3

PHPDoc tag @var for property App\Http\Controllers\CrudController::$datagridSorter with type App\Datagrids\Sorters\DatagridSorter|null is not subtype of native type App\Datagrids\Sorters\DatagridSorter.

/** @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');
Expand Down Expand Up @@ -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));
}
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/Entity/AbilityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public function edit(Campaign $campaign, Entity $entity, EntityAbility $entityAb
{
$this->authorize('update', $entity->child);
$ability = $entityAbility;
if (empty($ability->ability)) {
abort(403);
}

return view('entities.pages.abilities.update', compact(
'campaign',
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Families/Trees/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function entity(Campaign $campaign, Entity $entity): JsonResponse
*/
public function save(Request $request, Campaign $campaign, Family $family): JsonResponse
{
//dd($request->get('data'));
$this->authorize('update', $family);

return response()->json(
$this
->service
Expand Down
9 changes: 5 additions & 4 deletions app/Http/Controllers/RelationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ class RelationController extends CrudController
/** @var string Disable the sanitizer, handled by the observer */
protected string $sanitizer = '';

/** */
protected string $filter = RelationFilter::class;

public string $titleKey;

public function __construct(RelationService $relationService)
{
parent::__construct();
$this->middleware('auth');

$this->titleKey = __('sidebar.relations');
$this->relationService = $relationService;
}

public function titleKey(): string
{
return __('sidebar.relations');
}

/**
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\Response
* @throws \Illuminate\Auth\Access\AuthorizationException
Expand Down
Loading

0 comments on commit b6fccb6

Please sign in to comment.