Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for SeAT 5.0 with PHP 8.2 and Laravel 10 #70

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
}
},
"require": {
"eveseat/web": "^4.0",
"eveseat/eveapi": "^4.0",
"eveseat/notifications": "^4.0",
"eveseat/services": "^4.0",
"eveseat/eseye": "^2.1",
"eveseat/web": "^5.0",
"eveseat/eveapi": "^5.0",
"eveseat/notifications": "^5.0",
"eveseat/services": "^5.0",
"eveseat/eseye": "^3.0",
"s9e/text-formatter": "^2.4"
},
"authors": [{
Expand All @@ -24,13 +24,17 @@
"email": "[email protected]"
}],
"license": "GPL-3.0-or-later",
"minimum-stability": "alpha",
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"laravel": {
"providers": [
"Seat\\Kassie\\Calendar\\CalendarServiceProvider"
]
}
},
"require-dev": {
"rector/rector": "^0.18.3",
"driftingly/rector-laravel": "^0.24.1"
}
}
26 changes: 26 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use RectorLaravel\Set\LaravelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets(sets: [
LevelSetList::UP_TO_PHP_82,
SetList::CODE_QUALITY,
SetList::TYPE_DECLARATION,
LaravelSetList::LARAVEL_100
]);
};
20 changes: 10 additions & 10 deletions src/CalendarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class CalendarServiceProvider extends AbstractSeatPlugin
{
public function boot()
public function boot(): void
{
$this->addCommands();
$this->addRoutes();
Expand All @@ -24,13 +24,13 @@ public function boot()
$this->addPublications();
$this->addObservers();

$this->app->booted(function () {
$this->app->booted(function (): void {
$schedule = $this->app->make(Schedule::class);
$schedule->command('calendar:remind')->everyMinute();
});
}

public function register()
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/Config/package.sidebar.php', 'package.sidebar');
$this->mergeConfigFrom(__DIR__ . '/Config/calendar.character.menu.php', 'package.character.menu');
Expand All @@ -41,27 +41,27 @@ public function register()
$this->registerPermissions(__DIR__ . '/Config/Permissions/corporation.php', 'corporation');
}

private function addRoutes()
private function addRoutes(): void
{
$this->loadRoutesFrom(__DIR__ . '/Http/routes.php');
}

private function addViews()
private function addViews(): void
{
$this->loadViewsFrom(__DIR__ . '/resources/views', 'calendar');
}

private function addTranslations()
private function addTranslations(): void
{
$this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'calendar');
}

private function addMigrations()
private function addMigrations(): void
{
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
}

private function addPublications()
private function addPublications(): void
{
$this->publishes([
__DIR__ . '/resources/assets/css' => public_path('web/css'),
Expand All @@ -71,12 +71,12 @@ private function addPublications()
]);
}

private function addObservers()
private function addObservers(): void
{
Operation::observe(OperationObserver::class);
}

private function addCommands()
private function addCommands(): void
{
$this->commands([
RemindOperation::class,
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/RemindOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class RemindOperation extends Command
/**
* Process the command.
*/
public function handle()
public function handle(): void
{
# Ensure we send reminders starting with furthest in the future. That way
# when more than one event is being reminded, the last reminder in chat
# is the next event to occur.
$configured_marks = setting('kassie.calendar.notify_operation_interval', true);
if ($configured_marks === null || !setting('kassie.calendar.slack_integration', true)) return;
$marks = explode(',', $configured_marks);
$marks = explode(',', (string) $configured_marks);
rsort($marks);

foreach ($marks as $mark)
Expand Down
19 changes: 9 additions & 10 deletions src/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class Helper
* @param $emoji_empty
* @return string
*/
public static function ImportanceAsEmoji($importance, $emoji_full, $emoji_half, $emoji_empty) {
public static function ImportanceAsEmoji($importance, string $emoji_full, string $emoji_half, string $emoji_empty): string {
$output = "";

$tmp = explode('.', $importance);
$tmp = explode('.', (string) $importance);
$val = $tmp[0];
$dec = 0;

Expand Down Expand Up @@ -48,11 +48,10 @@ public static function ImportanceAsEmoji($importance, $emoji_full, $emoji_half,
public static function BuildSlackNotificationAttachment($op) {
$url = url('/calendar/operation', [$op->id]);

$fields = array();
$fields = [];

$fields[trans('calendar::seat.starts_at')] = $op->start_at->format('F j @ H:i EVE');
$fields[trans('calendar::seat.duration')] = $op->getDurationAttribute() ?
$op->getDurationAttribute() : trans('calendar::seat.unknown');
$fields[trans('calendar::seat.duration')] = $op->getDurationAttribute() ?: trans('calendar::seat.unknown');

$fields[trans('calendar::seat.importance')] =
self::ImportanceAsEmoji(
Expand All @@ -61,12 +60,12 @@ public static function BuildSlackNotificationAttachment($op) {
setting('kassie.calendar.slack_emoji_importance_half', true),
setting('kassie.calendar.slack_emoji_importance_empty', true));

$fields[trans('calendar::seat.fleet_commander')] = $op->fc ? $op->fc : trans('calendar::seat.unknown');
$fields[trans('calendar::seat.staging_system')] = $op->staging_sys ? $op->staging_sys : trans('calendar::seat.unknown');
$fields[trans('calendar::seat.staging_info')] = $op->staging_info ? $op->staging_info : trans('calendar::seat.unknown');
$fields[trans('calendar::seat.description')] = $op->description ? $op->description : trans('calendar::seat.unknown');
$fields[trans('calendar::seat.fleet_commander')] = $op->fc ?: trans('calendar::seat.unknown');
$fields[trans('calendar::seat.staging_system')] = $op->staging_sys ?: trans('calendar::seat.unknown');
$fields[trans('calendar::seat.staging_info')] = $op->staging_info ?: trans('calendar::seat.unknown');
$fields[trans('calendar::seat.description')] = $op->description ?: trans('calendar::seat.unknown');

return function ($attachment) use ($op, $url, $fields) {
return function ($attachment) use ($op, $url, $fields): void {
$attachment->title($op->title, $url)
->fields($fields)
->footer(trans('calendar::seat.created_by') . ' ' . $op->user->name)
Expand Down
63 changes: 20 additions & 43 deletions src/Http/Controllers/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public function getOngoing()
{
$operations = Operation::with('tags', 'fleet_commander', 'attendees', 'staging')
->where('start_at', '<', carbon()->now())
->where(function ($query) {
->where(function ($query): void {
$query->where('end_at', '>', carbon()->now());
$query->orWhereNull('end_at');
})
->where(function ($query) {
->where(function ($query): void {
if (! auth()->user()->isAdmin()) {
$query->whereIn('role_name', auth()->user()->roles->pluck('title')->toArray());
$query->orWhereNull('role_name');
Expand All @@ -44,7 +44,7 @@ public function getOngoing()
public function getIncoming()
{
$operations = Operation::with('tags', 'fleet_commander', 'attendees', 'staging')
->where(function ($query) {
->where(function ($query): void {
if (! auth()->user()->isAdmin()) {
$query->whereIn('role_name', auth()->user()->roles->pluck('title')->toArray());
$query->orWhereNull('role_name');
Expand All @@ -62,11 +62,11 @@ public function getIncoming()
public function getFaded()
{
$operations = Operation::with('tags', 'fleet_commander', 'attendees', 'staging')
->where(function ($query) {
->where(function ($query): void {
$query->where('start_at', '<', carbon()->now())
->where('end_at', '<', carbon()->now());
})
->where(function ($query) {
->where(function ($query): void {
if (! auth()->user()->isAdmin()) {
$query->whereIn('role_name', auth()->user()->roles->pluck('title')->toArray());
$query->orWhereNull('role_name');
Expand All @@ -85,7 +85,7 @@ public function getDetail($operation_id)
{
if (auth()->user()->can('calendar.view')) {
$op = Operation::with('tags')->find($operation_id);
return view('calendar::operation.modals/details.content', compact('op'));
return view('calendar::operation.modals/details.content', ['op' => $op]);
}

return redirect()
Expand All @@ -94,25 +94,16 @@ public function getDetail($operation_id)
}

/**
* @param Builder $operations
* @return mixed
*/
private function buildOperationDataTable(Builder $operations)
{
return app('datatables')::of($operations)
->editColumn('title', function ($row) {
return view('calendar::operation.partials.title', compact('row'));
})
->editColumn('tags', function ($row) {
return view('calendar::operation.partials.tags', ['op' => $row]);
})
->editColumn('importance', function ($row) {
return view('calendar::operation.partials.importance', ['op' => $row]);
})
->editColumn('start_at', function ($row) {
return sprintf('<span data-toggle="tooltip" title="%s">%s</span>',
$row->start_at, human_diff($row->start_at));
})
->editColumn('title', fn($row) => view('calendar::operation.partials.title', ['row' => $row]))
->editColumn('tags', fn($row) => view('calendar::operation.partials.tags', ['op' => $row]))
->editColumn('importance', fn($row) => view('calendar::operation.partials.importance', ['op' => $row]))
->editColumn('start_at', fn($row): string => sprintf('<span data-toggle="tooltip" title="%s">%s</span>',
$row->start_at, human_diff($row->start_at)))
->editColumn('end_at', function ($row) {
if ($row->end_at) {
return sprintf('<span data-toggle="tooltip" title="%s">%s</span>',
Expand All @@ -121,30 +112,16 @@ private function buildOperationDataTable(Builder $operations)
return '<span data-toggle="tooltip" title="no end set"></span>';
}
})
->editColumn('fleet_commander', function ($row) {
return view('calendar::operation.partials.fleet_commander', ['op' => $row]);
})
->addColumn('duration', function ($row) {
return sprintf('<span data-toggle="tooltip" title="%s">%s</span>',
$row->end_at, $row->duration);
})
->editColumn('staging_sys', function ($row) {
return view('calendar::operation.partials.staging', ['op' => $row]);
})
->addColumn('subscription', function ($row) {
return view('calendar::operation.partials.registration', ['op' => $row]);
})
->addColumn('actions', function ($row) {
return view('calendar::operation.partials.actions.actions', ['op' => $row]);
})
->setRowClass(function ($row) {
return $row->is_cancelled == 0 ? 'text-muted' : 'danger text-muted';
})
->addRowAttr('data-attr-op', function ($row) {
return $row->id;
})
->editColumn('fleet_commander', fn($row) => view('calendar::operation.partials.fleet_commander', ['op' => $row]))
->addColumn('duration', fn($row): string => sprintf('<span data-toggle="tooltip" title="%s">%s</span>',
$row->end_at, $row->duration))
->editColumn('staging_sys', fn($row) => view('calendar::operation.partials.staging', ['op' => $row]))
->addColumn('subscription', fn($row) => view('calendar::operation.partials.registration', ['op' => $row]))
->addColumn('actions', fn($row) => view('calendar::operation.partials.actions.actions', ['op' => $row]))
->setRowClass(fn($row): string => $row->is_cancelled == 0 ? 'text-muted' : 'danger text-muted')
->addRowAttr('data-attr-op', fn($row) => $row->id)
->rawColumns(['title', 'tags', 'importance', 'start_at', 'end_at', 'duration',
'fleet_commander', 'staging_sys', 'subscription', 'actions'])
->make(true);
->toJson();
}
}
7 changes: 2 additions & 5 deletions src/Http/Controllers/CharacterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
class CharacterController extends Controller
{
/**
* @param \Seat\Eveapi\Models\Character\CharacterInfo $character
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function paps(CharacterInfo $character)
Expand All @@ -37,7 +35,7 @@ public function paps(CharacterInfo $character)
$shipTypePaps = InvType::rightJoin('invGroups', 'invGroups.groupID', '=', 'invTypes.groupID')
->leftJoin('kassie_calendar_paps', 'ship_type_id', '=', 'typeID')
->where('categoryID', 6)
->where(function($query) use ($character) {
->where(function($query) use ($character): void {
$query->where('character_id', $character->character_id)
->orWhere('character_id', null);
})
Expand Down Expand Up @@ -67,7 +65,6 @@ public function paps(CharacterInfo $character)
->orderBy('qty', 'desc')
->get();

return view('calendar::character.paps', compact('monthlyPaps', 'shipTypePaps',
'weeklyRanking', 'monthlyRanking', 'yearlyRanking', 'character'));
return view('calendar::character.paps', ['monthlyPaps' => $monthlyPaps, 'shipTypePaps' => $shipTypePaps, 'weeklyRanking' => $weeklyRanking, 'monthlyRanking' => $monthlyRanking, 'yearlyRanking' => $yearlyRanking, 'character' => $character]);
}
}
Loading